Commit Graph

34 Commits

Author SHA1 Message Date
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
239a95e683 Fix typo: substring → substr 2016-06-05 18:00:01 +02:00
Alex Schroeder
58e9a1e240 use v5.10 everywhere + enabled test in meta.t 2015-08-18 10:48:03 +02:00
Alex Schroeder
1c776e1080 Undo the commit of version numbers 2015-08-17 16:54:07 +02:00
Alex Schroeder
f98374df9b PrintFooter relies on @MyFooters
We already called all the subs on @MyFooters and printed the result,
but this commit moves all the code from PrintFooters into subs and
puts those subs on @MyFooters. This allows us to write modules that
can better control where exactly their output should appear. In this
case the change was required in order to allow the Google +1 module to
coexist with code that maybe prints the comment form for all pages.

For example, knowing that the Google +1 sub is the first on one the
list because of unshift(@MyFooters, \&GooglePlusPrintFooter), we can
now write the following:

splice(@MyFooters, 1, 0, \&MyCommentsInTheFooter);

sub MyCommentsInTheFooter {
  my ($id, $rev, $comment) = @_;
  if (not $GooglePlusThisPagePrintedJournal
      and (GetParam('action', 'browse') eq 'browse'
           and $id and $CommentsPrefix
	   and $id ne $RCName
      	   and $id !~ /^$CommentsPrefix(.*)/o)) {

    my $target = $CommentsPrefix . $id;
    my $page = '';
    $page = PageHtml($target) if $IndexHash{$target};
    return $q->div({-class=>'comment'},
		   $q->h2(T('Comments')),
		   $page)
	. GetCommentForm("$CommentsPrefix$id", $rev, $comment);
  }
}

The Google +1 extension was also fixed to not triger the EFF's Privacy
Badger. This is OK because we're using a two step button: The user
needs to click a button before we're loading the script from Google.
2015-08-17 13:39:34 +02:00
Aleks-Daniel Jakimenko
4b49c1d326 No more variables declared in conditional statements (in modules) 2015-05-02 04:03:30 +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
f09a81b3b9 referrer-tracking: Get rid of CreatePageDir.
Fix the unit tests, too.
2014-06-23 12:19:07 +02:00
Alex Schroeder
365d33b602 Get rid of one letter sub-directories.
Recent GNU/Linux systems use ext3 or ext4 file systems. These use HTree
to index files. Wikipedia says: "HTree indexing improved the scalability
of Linux ext2 based filesystems from a practical limit of a few thousand
files, into the range of tens of millions of files per directory. [...]
HTree indexes are available in ext3 when the dir_index feature is
enabled. [...] HTree indexes are turned on by default in ext4."

Thus, instead of working on balanced-page-directories.pl, we decided to
get rid of these sub-directories altogether.

Unfortunately, this is backwards incompatible. Users wanting to upgrade
will need to install the upgrade.pl extension in order to upgrade the
file database.
2014-06-06 17:32:44 +02:00
Alex Schroeder
08b7674ab4 Use decoded_content for HTTP::Response 2012-10-26 16:38:22 +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
a85b26bc87 (ExpireReferers, UrlToTitle)
(GetReferers, PageContentToTitle, UpdateReferers): Get rid of
charset handling.
2011-02-24 22:47:11 +00:00
Alex Schroeder
8367bdfdf4 (UrlToTitle): Add charset arg.
(GetReferers): Pass charset to UrlToTitle.
(PageContentToTitle): Add charset arg and encode title
appropriately if not UTF-8.
(UpdateReferers): Pass charset to PageContentToTitle.
2010-10-27 18:17:16 +00:00
Alex Schroeder
dc5e6638a9 *** empty log message *** 2010-10-24 12:16:10 +00:00
Alex Schroeder
8f61c14677 (UrlToTitle): Strip http:// prefix and .html suffix.
(PageContentToTitle): Fix regular expressions.
2010-10-24 12:15:53 +00:00
Alex Schroeder
bb0f1e9e67 (GetReferers): Fix split. 2010-10-24 12:09:17 +00:00
Alex Schroeder
58122af58b (UrlToTitle, PageContentToTitle): Shorten title if necessary.
($RefererTitleLimit): New.
2010-10-23 13:31:07 +00:00
Alex Schroeder
c4c79ab585 Updated license to GPL 3.
(ExpireReferers): Moved code to generate missing title to a new sub.
(UrlToTitle): New.
(UpdateReferers): Call sub to generate title from page content.
(PageContentToTitle): New.
2010-10-23 13:08:08 +00:00
Alex Schroeder
08d04cc650 (PrintAllReferers): Use GetPageLink
instead of using ScriptLink directly in order to fix the output
for pages containing a space.
2009-02-18 23:13:35 +00:00
Alex Schroeder
2aed03e96b (PrintAllReferers): Add div.page
around each page entry.
(GetReferers): Removed HR.
2006-12-22 01:27:48 +00:00
Alex Schroeder
4c3251cd54 (RefererMenu): Add class to menu
entry.
2006-08-06 11:48:07 +00:00
Alex Schroeder
a9e71643dd (RefererInit): Replaced @AdminPages
with %AdminPages.
2006-07-15 23:14:22 +00:00
Alex Schroeder
9ff209a21e added comment with the utf-8 regexp for future work 2006-04-02 19:48:53 +00:00
Alex Schroeder
ee564154d0 (UpdateReferers): Extract charset from the content-type. 2006-04-02 19:29:10 +00:00
Alex Schroeder
ae63dffa30 (GetReferers): Extract valid URL using $FullUrlPattern just to be
safe.
2006-04-02 18:08:42 +00:00
Alex Schroeder
ab23d420a7 (GetReferers): Only decode the
title if the referrer charset is the same as the local charset.
(UpdateReferers): Store charset.
2006-04-02 17:24:29 +00:00
Alex Schroeder
58911a451f Removed $DefaultStyleSheet. 2005-10-09 00:55:43 +00:00
Alex Schroeder
0c733f31b4 (RefererTrack): No refererrers
unless there is a page id they belong to.
2005-09-18 10:26:57 +00:00
Alex Schroeder
870c34c997 (RefererNewPrintFooter): Removed $RefererTracking. 2005-01-07 00:54:29 +00:00
Alex Schroeder
1f5088df9d Moved from wiki.pl. 2005-01-07 00:50:34 +00:00