Commit Graph

23 Commits

Author SHA1 Message Date
Alex Schroeder
a91ef8602f Moving modules from utf8::encode to encode_utf8 2016-06-22 15:37:04 +02:00
Alex Schroeder
f992897e7a opendir also requires bytes 2016-06-19 15:55:03 +02:00
Alex Schroeder
83f13a9a1a Use helper functions for accessing the file system
As we derive a lot of filenames from strings in UTF-8 encoded files, we
need to make sure that any filename that might might be set by a user –
including all the filenames containing a directory deriving from
$DataDir – are passed through utf8::encode. That is, every character
gets replaced with a sequence of one or more characters that represent
the individual bytes of the character and the UTF8 flag is turned off.

In other words, -d $DataDir might not work if $DataDir contains a UTF-8
encoded string. The solution is to use the following replacements:

-f $name            IsFile($name)
-e $name            IsFile($name)
-d $name            IsDir($name)
(stat($name))[9]    Modified($name)
-M $name            $Now - Modified($name)
-z $name            ZeroSize($name)
unlink $name        Unlink($name)
mkdir $name         CreateDir($name)
rmdir $name         RemoveDir($name)

(Using IsFile for -e is probably not ideal?)

If you don’t, and Oddmuse gets used with Mojolicious, and you use the
Namespaces Extension, and a namespace contains non-ASCII characters such
as ä, ö, or ü, these characters will end up as part of $DataDir and
trigger the problem.

I also wonder whether we should be using some other Perl library.
2016-06-17 14:49:34 +02:00
Alex Schroeder
58e9a1e240 use v5.10 everywhere + enabled test in meta.t 2015-08-18 10:48:03 +02:00
Aleks-Daniel Jakimenko
f782691e7e UTF-8, again! Also, new ToString sub. 2015-05-17 03:35:35 +03:00
Aleks-Daniel Jakimenko
a615bedccf Fixed a bunch of stuff 2015-04-28 00:03:11 +03:00
Aleks-Daniel Jakimenko
df87ff82c3 No more redundant 'package OddMuse;' 2015-04-27 17:41:59 +03:00
Aleks-Daniel Jakimenko
40ec24349a No more "*Sub = *NewSub", \&NewSub used instead. (Partial progress) 2015-04-11 23:41:33 +03:00
Aleks-Daniel Jakimenko
6f8d281d79 No more "use vars"! 2015-04-10 13:31:28 +03:00
Aleks-Daniel Jakimenko
4492ede096 "use strict;" in modules (some modules have problems) 2015-03-27 03:01:01 +02:00
Alex Schroeder
5aba2ae56f Fixed typo in AddModuleDescription sub name 2014-08-21 22:23:23 +02:00
Alex Jakimenko
a7f83b2ba7 Added file descriptions without wiki links 2014-08-21 16:41:32 +03:00
Alex Schroeder
48ec41b566 git: added git.t, rewrote git.pl
Tests were added. As I wrote the tests, I realized that GitRun was
printing to STDOUT even though we had created a local *STDOUT and opened
it to write to a memory file (like PageHtml does). Apparently this is
not inherited to the child process. I now use the solution provided for
in the perldoc for open. Unfortunately it requires a temp file. Trying
to use a memory file results in an error. Temporary files are a mess if
I want to access the output: I need to close it and reopen it for
reading. That's why GitRun only does that if $GitDebug is set. This is
what most of the tests will use: set $GitDebug and examine $GitResult.
At the same time I realized that the error message was never being
triggered. The previous code was tricky because it only considered
showing an error message in a non-void context, ie. when called from
maintenance. I wasn't sure this was an actual benefit and decided to
remove it altogether. I we really want to, we can set $GitDebug and
examine $GitResult in GitCleanup.
2014-07-31 13:18:32 +02:00
Alex Jakimenko
252033bff8 git.pl: Some significant changes.
Added: $GitPageFile variable. Set it to true if you want to keep
complete page files in git and not just text.

Fixed: previously git extension was chdir-ing into $GitRepo directory
without ever going back, this could have lead to problems if some other
code needed access to file system.

Fixed: now this extension will work smoothly if $DataDir is set to a
relative path.

Fixed: this extension was probably broken for wiki pages starting with
two dashes (e.g. --SomePage), this is now fixed by using -- to indicate
the end of command-line options.

Changed: GitCleanup is now using GitRun instead of backticks (like
everywhere else). It will also print the exit status of 'git commit'
command.

Changed: some tiny style improvements.
2014-07-30 14:06:07 +02:00
Alex Schroeder
355874edad Add git action to call GitCleanup directly. Add more print statements explaining what git is doing. 2013-02-28 10:44:26 +01:00
Alex Schroeder
60a5a8fcee git.pl: run "git add ." as part of maintenance. 2012-08-14 21:41:19 +02:00
Alex Schroeder
6dd6acee00 Renamed $GitDir to $GitRepo. 2011-11-20 22:52:18 +00:00
Alex Schroeder
42bf6bcd2e *** empty log message *** 2011-11-05 13:19:06 +00:00
Alex Schroeder
bb294db6bb * git.pl (GitCleanup): Get rid of git add --all and use
git commit -a instead.
2011-11-04 22:59:03 +00:00
Alex Schroeder
0a2944d208 *** empty log message *** 2011-11-04 22:42:26 +00:00
Alex Schroeder
cb7f7d4b69 (GitNewSave, GitNewDeletePage, GitCleanup): Use $GitMail. 2011-10-23 19:16:38 +00:00
Alex Schroeder
41451bba69 ($GitMail): New option.
(GitInitRepository): Use it.
2011-10-23 18:11:29 +00:00
Alex Schroeder
bb5f0b2106 New 2011-10-22 23:17:12 +00:00