Commit Graph

57 Commits

Author SHA1 Message Date
Alex Schroeder
74288ba3f3 Moving from utf8::encode to encode_utf8 2016-06-22 14:43:28 +02:00
Alex Schroeder
c121607f61 All open and tie calls need utf8::encode 2016-06-19 13:51:11 +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
Aleks-Daniel Jakimenko-Aleksejev
8a36970b24 static-copy.pl: Fix non-ascii links
It seems like it is operating on url-encoded strings, so all we have to
do is to decode it. This, however, does not mean that we should print
decoded strings. ‘href’ attribute still has to be encoded (or so it seems).
2016-02-02 20:22:06 +02:00
Aleks-Daniel Jakimenko-Aleksejev
89a23a6ac5 Full support for arrayref in $StyleSheet 2015-10-26 01:03:42 +02:00
Aleks-Daniel Jakimenko
1c4e082755 Return objects where it begs for it
sub ParseData is fully backwards compatible. If some module runs it in list
context, then it will get listified hash like previously. New code should
always run it in scalar context though (everything in our code base
was changed according to that).

sub GetTextRevision is not backwards compatible (don't let “wantarray” usage
to confuse you). Most modules do not touch that subroutine, so we are probably
fine (modules from our git repo that do use were changed accordingly).

“EncodePage(%$page)” looks wrong. It seems like we should change it to accept
hash ref.
2015-09-04 04:55:48 +03:00
Alex Schroeder
c96b9bb71c static-copy.pl: do not mess with GetCommentForm
This used to be necessary because we used PrintFooter. As static-copy.pl
no longer uses PrintFooter, this futzing is unnecessary and was removed.
2015-08-18 12:35:31 +02:00
Alex Schroeder
58e9a1e240 use v5.10 everywhere + enabled test in meta.t 2015-08-18 10:48:03 +02:00
Alex Schroeder
22bf1e8df3 static-copy.t skips a test without HTTPS support
The static.css file is copied from https://oddmuse.org/ -- so if
LWP::Protocol::https is not installed, this cannot work.
2015-07-21 12:42:06 +02:00
Alex Schroeder
a767bb5c94 static-copy.pl use HTTPS to access oddmuse.org 2015-07-21 12:22:39 +02:00
Aleks-Daniel Jakimenko
f782691e7e UTF-8, again! Also, new ToString sub. 2015-05-17 03:35:35 +03:00
Alex Schroeder
615a78f0b7 static-copy.pl: fix partial change from F to $F
The file writing operations had been only partially changed from F to
$F. Unfortunately, the old code relied on the fact that a file glob like
F was global in scope. To make the change to the file handle variable
more obvious, $F was renamed to $fh and this variable is now passed to
the subroutines StaticFile and StaticHtml.

In addition to that, :encoding(UTF-8) was changed back to :utf8 because
sometimes, this didn't work as intended.
2015-05-15 16:31:47 +02:00
Aleks-Daniel Jakimenko
26b0853e13 No more two-arg open 2015-05-02 03:19:25 +03:00
Aleks-Daniel Jakimenko
a615bedccf Fixed a bunch of stuff 2015-04-28 00:03:11 +03:00
Aleks-Daniel Jakimenko
17b2562054 No more "*Sub = *NewSub", \&NewSub used instead. (Completely now!) 2015-04-12 22:50:50 +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
ee932dee37 Automatically reformatted modules 2014-08-21 07:29:46 +03:00
Alex Schroeder
d7c40d4dbe Fix dead comment links
If the comment page does not exist, the static copy contains an anchor
element with no href attribute. Better avoid this situation.
2014-03-18 13:01:27 +01:00
Alex Schroeder
f8360bebad Produce static.css as well when exporting 2014-03-18 12:47:16 +01:00
Alex Schroeder
45a0558fcc Fixing the UTF-8 encoding issues for static export 2014-03-18 11:49:28 +01:00
Alex Schroeder
f4ff56e69f Fix HTML output for static export 2014-03-18 11:21:08 +01:00
Alex Schroeder
686f24251b Fix static export of HTML pages
Apparently the html=1 parameter got lost so that you could not force an
export of all the pages.
2014-03-18 09:26:04 +01:00
Alex Schroeder
8e1f6c92e3 Static action now takes $StaticAlways into account. 2013-10-25 08:49:13 +02:00
Alex Schroeder
cd2b4d624e Remove $HttpCharset and moved everything to UTF-8
This also required some changes to the tests where explicit UTF-8
encoding had been used in the past.
2012-05-22 11:50:23 +02:00
Alex Schroeder
f11e2a8731 getting rid of $Id$ tags in $WikiDescription
Replaced the $Id$ tags in $WikiDescription for all the modules and wiki.pl itself with a link to the source and an appropriate wiki page, if possible. This is shown in action=version and should help users figure out what another wiki has installed.
2012-04-19 02:18:45 +02:00
Alex Schroeder
f6d4789190 (StaticFileName, StaticWriteFile): Handle
encoded files, eg. gzip.
2011-10-13 23:46:21 +00:00
Alex Schroeder
c7d3346690 (StaticFileName): Don't just print
something to stdout if the target page does not exist, yet. This
will always happen when creating a link to an image before
upoading the image!
2009-05-15 20:25:35 +00:00
Alex Schroeder
970c7f9cfd (ImageGetInternalUrl): Call FreeToNormal
on the argument.
2008-12-14 23:59:12 +00:00
Alex Schroeder
17f5e04ad1 (StaticFilesNewDoPost,
StaticFilesNewSave): Replace one by the other. We now hook into
Save() instead of DoPost() because this will make sure that static
files are recreated when a rollback from a text to an uploaded
file happens.
2007-08-12 11:37:01 +00:00
Alex Schroeder
7b19458768 (StaticHtml): Fix bug. Target is $1 and not $id. 2006-10-25 11:30:31 +00:00
Alex Schroeder
758c811c93 (StaticHtml): Fix bug. Target is $1 and not $id. 2006-10-25 11:23:44 +00:00
Alex Schroeder
4968c95ba1 (StaticHtml): Handle #REDIRECT. 2006-10-25 11:16:24 +00:00
Alex Schroeder
7c28b10e9e (StaticScriptLink): Remove unnecessary call to AllPagesList.
(StaticGetDownloadLink): Strip underlines from alt texts, return
URL only when requested (matches changes in wiki.pl's GetDownloadLink.
(GetDownloadLink): Ditto.
2006-08-13 23:10:49 +00:00
Alex Schroeder
85c2b08a85 (DoStatic, StaticFileName): Don't set
%StaticMimeTypes in DoStatic, as this has no effect here when
GetDownloadLink is called. StaticFileName is the right place.
2006-08-11 21:20:00 +00:00
Alex Schroeder
189f89ec2a Fix typo in init code. 2006-08-09 18:21:23 +00:00
Alex Schroeder
878b9f040e copy right year 2005-12-29 16:02:08 +00:00
Alex Schroeder
237c275b3c (StaticFileName): Use UrlDecode.
(StaticUrlDecode): Removed.
2005-09-02 12:05:48 +00:00
Sebastian Blatt
40790c9c8b fixed permission on uploaded static copy 2005-03-09 06:35:54 +00:00
Sebastian Blatt
a55acb2baa Added Image extension support to Static Copy extension 2005-03-01 16:48:01 +00:00
Alex Schroeder
800288ec57 (StaticWriteFile): Don't write empty html files. 2004-12-29 00:52:27 +00:00
Alex Schroeder
27d4ed21f2 (StaticWriteFile): Add support for html=0
parameter.
2004-12-29 00:41:21 +00:00
Alex Schroeder
8dee0d4920 (GetDownloadLink): Use StaticFileName. 2004-12-26 01:39:00 +00:00
Alex Schroeder
571313a5a8 (StaticDeleteFile): New.
(GetStaticDownloadLink): New, override the one from wiki.pl.
2004-12-26 01:08:21 +00:00
Alex Schroeder
d4c53336c0 *** empty log message *** 2004-12-26 00:38:36 +00:00
Alex Schroeder
cc34793cfd (StaticFileName, StaticWriteFile): Regexp fix.
(StaticFilesNewDoPost, StaticNewDeletePage, StaticDeleteFile): New.
2004-12-26 00:29:27 +00:00
Alex Schroeder
da93f49418 (StaticScriptLink): Don't link to non-existing pages.
(StaticHtml): Handle comment pages.
2004-10-13 19:01:35 +00:00
Alex Schroeder
861090d049 (StaticFileName): Add <br/>.
(StaticHtml): Add h1 title, limited goto-bar, and footer.
2004-10-13 18:30:42 +00:00