Compare commits

...

18 Commits
2.2.3 ... 2.2.4

Author SHA1 Message Date
Alex Schroeder
d249792866 Changed the default CSS to oddmuse.org/default.css
I was often confused as to whether oddmuse.org/oddmuse.css referred to
the CSS used by oddmuse.org or to the CSS used by Oddmuse
installations without CSS setting.
2013-08-19 11:46:11 +02:00
Alex Schroeder
59cad086e7 Removed ban-yourself.pl because that was just an idea without any code. 2013-08-16 00:32:27 +02:00
Alex Schroeder
cfac228f57 Test for ban-quick-editors.pl 2013-08-16 00:31:28 +02:00
Alex Schroeder
a4bd6383a2 Quote the unquoted string "commenthidden". 2013-08-16 00:30:58 +02:00
Alex Schroeder
df0f470998 Don't delete pages that are "lock on creation".
This is meant to protect BannedContent and BannedHost from deletion.
2013-08-16 00:29:32 +02:00
Alex Schroeder
d61bf19b15 New module: don't allow quick editing by an IP or username. 2013-08-15 23:46:31 +02:00
Alex Schroeder
e0659c4d60 Made regular expression test more robust. 2013-08-05 10:02:06 +02:00
Alex Schroeder
70baed8088 Testing: Add tests to verify the process of banning URL fragments. 2013-08-02 17:27:50 +02:00
Alex Schroeder
ab3e187354 Bugfix: Banned URLs are added to BannedContent, not BannedHosts.
Added a separate link to add host or IP number to BannedHosts.
2013-08-02 17:13:44 +02:00
Alex Schroeder
f17a67d817 Convenience: List URLs rolled back and offer entry of regexp.
If you are an admin and rolled back a single page, this will list the
URLs your rollback removed (assuming that those URLs are part of the
spam) and it will allow you to provide a regular expression that will
be added to BannedHosts.
2013-08-02 16:55:49 +02:00
Alex Schroeder
601218c0b1 Added ban-contributors extension and tests. 2013-07-30 17:40:57 +02:00
Alex Schroeder
8af5095ff5 Hide Google+ stuff when printing. 2013-07-24 07:43:56 -04:00
Alex Schroeder
0a6cbfa20d Fix link given by raw history page. 2013-06-05 16:18:10 +02:00
Alex Schroeder
1630b64fa5 Fix critical bug in private-pages.pl.
Private pages were deleted whenever maintenance ran. This has been
fixed.
2013-05-30 16:15:01 +02:00
Alex Schroeder
ff4ad6e151 Merge branch 'master' of git.sv.gnu.org:/srv/git/oddmuse 2013-05-23 09:03:13 +02:00
Alex Schroeder
cc07341463 DoRollback prints a footer for a specific page if called for one page only.
The typical workflow when reverting spam:
1. view RecentChanges
2. click History button
3. click Rollback button
4. click Administration
5. click Ban contributors
6. click Ban!

This requires that the Administration link in #4 contains the page
id. This commit ensures it.
2013-05-23 09:02:46 +02:00
Alex Schroeder
9fd20a9e93 A new rollback testing idea. 2013-05-19 16:13:37 +02:00
Alex Schroeder
1a561c3cb1 Fix tagcloud bug in tags.pl.
The hash value wasn't being decoded before being split which resultet
in count being 1 in all cases.
2013-05-19 15:32:54 +02:00
13 changed files with 397 additions and 40 deletions

View File

@@ -398,7 +398,7 @@ p.table + p { clear:both; }
/* hide all the crap */
div.diff, div.diff+hr, div.refer, div.near, div.definition, div.sister,
div.cal, div.footer, span.specialdays, span.gotobar, a.edit, a.number span,
div.rc form, form.tiny, p.comment {
div.rc form, form.tiny, p.comment, p#plus1, div.g-plusone {
display:none;
}
a,

156
modules/ban-contributors.pl Normal file
View File

@@ -0,0 +1,156 @@
# Copyright (C) 2013 Alex Schroeder <alex@gnu.org>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
=head1 Ban Contributors Extension
This module adds "Ban contributors" to the administration page. If you
click on it, it will list all the recent contributors to the page
you've been looking at. Each contributor (IP or hostname) will be
compared to the list of regular expressions on the C<BannedHosts> page
(see C<$BannedHosts>). If the contributor is already banned, this is
mentioned. If the contributor is not banned, you'll see a button
allowing you to ban him or her immediately. If you click the button,
the IP or hostname will be added to the C<BannedHosts> page for you.
=cut
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/ban-contributors.pl">ban-contributors.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Ban_Contributors_Extension">Ban Contributors Extension</a></p>';
push(@MyAdminCode, \&BanMenu);
sub BanMenu {
my ($id, $menuref, $restref) = @_;
if ($id and UserIsAdmin()) {
push(@$menuref, ScriptLink('action=ban;id=' . UrlEncode($id),
T('Ban contributors')));
}
}
$Action{ban} = \&DoBanHosts;
sub IsItBanned {
my ($it, $regexps) = @_;
my $re = undef;
foreach my $regexp (@$regexps) {
eval { $re = qr/$regexp/i; };
if (defined($re) && $it =~ $re) {
return $it;
}
}
}
sub DoBanHosts {
my $id = shift;
my $content = GetParam('content', '');
my $host = GetParam('host', '');
if ($content) {
SetParam('text', GetPageContent($BannedContent)
. $content . " # " . CalcDay($Now) . " "
. NormalToFree($id) . "\n");
SetParam('summary', NormalToFree($id));
DoPost($BannedContent);
} elsif ($host) {
$host =~ s/\./\\./g;
SetParam('text', GetPageContent($BannedHosts)
. "^" . $host . " # " . CalcDay($Now) . " "
. NormalToFree($id) . "\n");
SetParam('summary', NormalToFree($id));
DoPost($BannedHosts);
} else {
ValidIdOrDie($id);
print GetHeader('', Ts('Ban Contributors to %s', NormalToFree($id)));
SetParam('rcidonly', $id);
SetParam('all', 1);
my %contrib = ();
for my $line (GetRcLines()) {
$contrib{$line->[4]}->{$line->[5]} = 1 if $line->[4];
}
my @regexps = ();
foreach (split(/\n/, GetPageContent($BannedHosts))) {
if (/^\s*([^#]\S+)/) { # all lines except empty lines and comments, trim whitespace
push(@regexps, $1);
}
}
print '<div class="content ban">';
foreach (sort(keys %contrib)) {
my $name = $_;
delete $contrib{$_}{''};
$name .= " (" . join(", ", sort(keys(%{$contrib{$_}}))) . ")";
if (IsItBanned($_, \@regexps)) {
print $q->p(Ts("%s is banned", $name));
} else {
print GetFormStart(undef, 'get', 'ban'),
GetHiddenValue('action', 'ban'),
GetHiddenValue('id', $id),
GetHiddenValue('host', $_),
GetHiddenValue('recent_edit', 'on'),
$q->p($name, $q->submit(T('Ban!'))), $q->end_form();
}
}
}
PrintFooter();
}
=head2 Rollback
If you are an admin and rolled back a single page, this extension will
list the URLs your rollback removed (assuming that those URLs are part
of the spam) and it will allow you to provide a regular expression
that will be added to BannedHosts.
=cut
*OldBanContributorsWriteRcLog = *WriteRcLog;
*WriteRcLog = *NewBanContributorsWriteRcLog;
sub NewBanContributorsWriteRcLog {
my ($tag, $id, $to) = @_;
if ($tag eq '[[rollback]]' and $id and $to > 0
and $OpenPageName eq $id and UserIsAdmin()) {
# we currently have the clean page loaded, so we need to reload
# the spammed revision (there is a possible race condition here)
my ($old) = GetTextRevision($Page{revision}-1, 1);
my %urls = map {$_ => 1 } $old =~ /$UrlPattern/og;
# we open the file again to force a load of the despammed page
foreach my $url ($Page{text} =~ /$UrlPattern/og) {
delete($urls{$url});
}
# we also remove any candidates that are already banned
my @regexps = ();
foreach (split(/\n/, GetPageContent($BannedContent))) {
if (/^\s*([^#]\S+)/) { # all lines except empty lines and comments, trim whitespace
push(@regexps, $1);
}
}
foreach my $url (keys %urls) {
delete($urls{$url}) if IsItBanned($url, \@regexps);
}
if (keys %urls) {
print $q->p(Ts("These URLs were rolled back. Perhaps you want to add a regular expression to %s?",
GetPageLink($BannedContent)));
print $q->pre(join("\n", sort keys %urls));
print GetFormStart(undef, 'get', 'ban'),
GetHiddenValue('action', 'ban'),
GetHiddenValue('id', $id),
GetHiddenValue('recent_edit', 'on'),
$q->p($q->label({-for=>'content'}, T('Regular expression:')), " ",
$q->textfield(-name=>'content', -size=>30), " ",
$q->submit(T('Ban!'))),
$q->end_form();
};
print $q->p(T("Consider banning the hostname or IP number as well: "),
ScriptLink('action=ban;id=' . UrlEncode($id), T('Ban contributors')));
};
return OldBanContributorsWriteRcLog(@_);
}

View File

@@ -0,0 +1,37 @@
# Copyright (C) 2013 Alex Schroeder <alex@gnu.org>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file must load before logbannedcontent.pl such that quick
# editors will be logged.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/ban-quick-editors.pl">ban-quick-editors.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Banning_Quick_Editors">Banning Quick Editors</a></p>';
*BanQuickOldUserIsBanned = *UserIsBanned;
*UserIsBanned = *BanQuickNewUserIsBanned;
sub BanQuickNewUserIsBanned {
my $rule = BanQuickOldUserIsBanned(@_);
if (not $rule
and $SurgeProtection # need surge protection
and GetParam('title')) {
my $name = GetParam('username', $ENV{'REMOTE_ADDR'});
my @entries = @{$RecentVisitors{$name}};
# $entry[0] is $Now after AddRecentVisitor
my $ts = $entries[1];
if ($Now - $ts < 5) {
return "fast editing spam bot";
}
}
return $rule;
}

View File

@@ -1,20 +1,16 @@
# Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
# Copyright (C) 2006-2013 Alex Schroeder <alex@gnu.org>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/delete-all.pl">delete-all.pl</a></p>';
@@ -27,6 +23,7 @@ $DeleteAge = 172800; # 2*24*60*60
# All pages will be deleted after two days of inactivity!
sub NewDelPageDeletable {
return 1 if $Now - $Page{ts} > $DeleteAge;
return 1 if $Now - $Page{ts} > $DeleteAge
and not $LockOnCreation{$OpenPageName};
return OldDelPageDeletable(@_);
}

View File

@@ -1,20 +1,16 @@
# Copyright (C) 2005 Alex Schroeder <alex@emacswiki.org>
# Copyright (C) 2005-2013 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/dynamic-comments.pl">dynamic-comments.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Dynamic_Comments_Extension">Dynamic Comments Extension</a></p>';
@@ -51,7 +47,7 @@ sub DynamicCommentsNewGetPageLink {
my $anchor = "id" . $num++;
return qq{<a href="javascript:togglecomments('$anchor')">$title</a>}
. '</p>' # close p before opening div
. $q->div({-class=>commenthidden, -id=>$anchor},
. $q->div({-class=>'commenthidden', -id=>$anchor},
$page,
$q->p(DynamicCommentsOldGetPageLink($id, T('Add Comment'))))
. '<p>'; # open an empty p that will be closed in PrintAllPages

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2012 Alex Schroeder <alex@gnu.org>
# Copyright (C) 20122013 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@@ -81,6 +81,16 @@ sub PrivatePageMessage {
. T('supply the password now') . ']');
}
# prevent unauthorized reading
# If we leave $Page{revision}, PrintWikiToHTML will save the new
# PrivatePageMessage as the new page content. If we delete
# $Page{revision}, the text shown will be based on $NewText. If we
# have no $Page{ts} and no $Page{text}, PageDeletable will return 1.
# As a workaround, we set a timestamp. Aging of the page doesn't
# matter since the text starts with #PASSWORD and therefore cannot be
# the empty string or $DeletedPage.
*OldPrivatePagesOpenPage = *OpenPage;
*OpenPage = *NewPrivatePagesOpenPage;
@@ -88,11 +98,14 @@ sub NewPrivatePagesOpenPage {
OldPrivatePagesOpenPage(@_);
if (PrivatePageLocked($Page{text})) {
%Page = (); # reset everything
$Page{ts} = $Now;
$NewText = PrivatePageMessage();
}
return $OpenPageName;
}
# prevent reading of page content by other code
*OldPrivatePagesGetPageContent = *GetPageContent;
*GetPageContent = *NewPrivatePagesGetPageContent;
@@ -104,6 +117,8 @@ sub NewPrivatePagesGetPageContent {
return $text;
}
# prevent reading of old revisions
*OldPrivatePagesGetTextRevision = *GetTextRevision;
*GetTextRevision = *NewPrivatePagesGetTextRevision;
@@ -115,6 +130,8 @@ sub NewPrivatePagesGetTextRevision {
return ($text, $revision);
}
# hide #PASSWORD
push(@MyRules, \&PrivatePageRule);
sub PrivatePageRule {
@@ -124,6 +141,8 @@ sub PrivatePageRule {
return undef;
}
# prevent leaking of edit summary
*OldPrivatePagesGetSummary = *GetSummary;
*GetSummary = *NewPrivatePagesGetSummary;

View File

@@ -292,7 +292,7 @@ sub TagCloud {
my $min = 0;
my %count = ();
foreach my $encoded_tag (grep !/^_/, keys %h) {
$count{$encoded_tag} = split(/$FS/, $h{$encoded_tag});
$count{$encoded_tag} = split(/$FS/, UrlDecode($h{$encoded_tag}));
$max = $count{$encoded_tag} if $count{$encoded_tag} > $max;
$min = $count{$encoded_tag} if not $min or $count{$encoded_tag} < $min;
}

55
t/ban-contributors.t Normal file
View File

@@ -0,0 +1,55 @@
# Copyright (C) 2013 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
require 't/test.pl';
package OddMuse;
use Test::More tests => 21;
clear_pages();
add_module('ban-contributors.pl');
$localhost = 'pyrobombus';
$ENV{'REMOTE_ADDR'} = $localhost;
update_page('Test', 'insults');
test_page_negative(get_page('action=admin id=Test'), 'Ban contributors');
test_page(get_page('action=admin id=Test pwd=foo'), 'Ban contributors');
test_page(get_page('action=ban id=Test pwd=foo'), 'pyrobombus', 'Ban!');
test_page(get_page('action=ban id=Test host=pyrobombus pwd=foo'),
'Location: http://localhost/wiki.pl/BannedHosts');
test_page(get_page('BannedHosts'), 'pyrobombus', 'Test');
clear_pages();
add_module('ban-contributors.pl');
update_page('Test', 'no spam');
ok(get_page('action=browse id=Test raw=2')
=~ /(\d+) # Do not delete this line/,
'raw=2 returns timestamp');
$to = $1;
ok($to, 'timestamp stored');
sleep(1);
update_page('Test', "http://spam/amoxil/ http://spam/doxycycline/");
test_page(get_page("action=rollback id=Test to=$to pwd=foo"),
'Rolling back changes', 'These URLs were rolled back',
'amoxil', 'doxycycline', 'Consider banning the hostname');
test_page(get_page("action=ban id=Test content=amoxil pwd=foo"),
'Location: http://localhost/wiki.pl/BannedContent');
test_page(get_page('BannedContent'), 'amoxil', 'Test');
update_page('Test', "http://spam/amoxil/ http://spam/doxycycline/");
$page = get_page("action=rollback id=Test to=$to pwd=foo");
test_page($page, 'Rolling back changes', 'These URLs were rolled back',
'doxycycline');
test_page_negative($page, 'amoxil');

34
t/ban-quick-editors.t Normal file
View File

@@ -0,0 +1,34 @@
# Copyright (C) 2013 Alex Schroeder <alex@gnu.org>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
require 't/test.pl';
package OddMuse;
use Test::More tests => 3;
clear_pages();
# switch it back on again
AppendStringToFile($ConfigFile, "\$SurgeProtection = 1;\n");
# make sure the visitors.log is filled
$ENV{'REMOTE_ADDR'} = '127.0.0.1';
add_module('ban-quick-editors.pl');
get_page('Test');
test_page(update_page('Test', 'cannot edit'),
'This page is empty');
test_page($redirect, 'Editing not allowed');
sleep 5;
test_page(update_page('Test', 'edit succeeded'),
'edit succeeded');

View File

@@ -14,7 +14,7 @@
require 't/test.pl';
package OddMuse;
use Test::More tests => 73;
use Test::More tests => 77;
use utf8; # tests contain UTF-8 characters and it matters
clear_pages();
@@ -41,6 +41,15 @@ test_page(get_page('action=browse id=Test ns=Muu'),
'<title>Wiki Muu: Test</title>',
'<p>Mooo!</p>');
# history
xpath_test(get_page('action=history id=Test ns=Muu'),
'//table[@class="history"]/tr/td/a[text()="Revision 1"]',
'//h1[text()="History of Test"]');
test_page(get_page('action=history id=Test ns=Muu raw=1'),
"link: http://localhost/wiki.pl/Muu\\?action=history;id=Test;raw=1\n",
"link: http://localhost/wiki.pl/Muu/Test\n");
# search
$page = get_page('/Muu?search=Mooo raw=1');
test_page($page, 'description: Mooo!');

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2012 Alex Schroeder <alex@gnu.org>
# Copyright (C) 20122013 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@@ -14,7 +14,7 @@
require 't/test.pl';
package OddMuse;
use Test::More tests => 28;
use Test::More tests => 29;
clear_pages();
add_module('private-pages.pl');
@@ -32,6 +32,10 @@ test_page_negative(update_page('Privat', "#PASSWORD foo\nCats have secrets.\n",
'Cats have secrets');
test_page($redirect, 'Status: 302');
# is not deleted by maintenance job
my $page = get_page('action=maintain');
test_page($page, 'Privat');
# read it with password
my $page = get_page('action=browse id=Privat pwd=foo');
test_page_negative($page, 'This page is password protected');

50
t/rollback-extras.t Normal file
View File

@@ -0,0 +1,50 @@
# Copyright (C) 2013 Alex Schroeder <alex@gnu.org>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
require 't/test.pl';
package OddMuse;
use Test::More tests => 3;
# simple, single page rollback
# ($ts, $id, $minor, $summary, $host, $username, $revision, $languages, $cluster)
# ($ts, '[[rollback]]', $to, $page)
clear_pages();
WriteStringToFile ($RcFile, "1Aone1\n"); # original
AppendStringToFile($RcFile, "2Atwo2\n"); # to be rolled back
AppendStringToFile($RcFile, "3A0one3\n"); # back to the original
AppendStringToFile($RcFile, "3[[rollback]]1A\n"); # rollback marker
local $/ = "\n"; # undef in test.pl
my @lines = GetRcLines(1);
is(scalar(@lines), 1, "starting situation contains just one line");
is($lines[0][0], 3, "simple rollback starts with 3");
AppendStringToFile($RcFile, "4Athree4\n");
# print "GetRcLines\n";
# for my $line (GetRcLines(1)) {
# my ($ts, $id, $minor, $summary) = @$line;
# print "$ts, $id, $minor, $summary\n";
# }
SetParam('all', 1);
my @lines = GetRcLines(1);
is(scalar(@lines), 4, "using all=1, see all four major revisions");
# This could be an interesting test framework.

View File

@@ -1969,7 +1969,7 @@ sub DoHistory {
print GetHttpHeader('text/plain'),
RcTextItem('title', Ts('History of %s', NormalToFree($OpenPageName))),
RcTextItem('date', TimeToText($Now)),
RcTextItem('link', $q->url(-path_info=>1, -query=>1)),
RcTextItem('link', ScriptUrl("action=history;id=$OpenPageName;raw=1")),
RcTextItem('generator', 'Oddmuse');
SetParam('all', 1);
my @languages = split(/,/, $Page{languages});
@@ -2104,7 +2104,7 @@ sub DoRollback {
WriteRcLog('[[rollback]]', $page, $to); # leave marker
print $q->end_p() . $q->end_div();
ReleaseLock();
PrintFooter();
PrintFooter($page);
}
sub DoAdminPage {
@@ -2356,7 +2356,7 @@ sub GetCss { # prevent javascript injection
push (@css, $StyleSheet) if $StyleSheet and not @css;
push (@css, "$ScriptName?action=browse;id=" . UrlEncode($StyleSheetPage) . ";raw=1;mime-type=text/css")
if $IndexHash{$StyleSheetPage} and not @css;
push (@css, 'http://www.oddmuse.org/oddmuse.css') unless @css;
push (@css, 'http://www.oddmuse.org/default.css') unless @css;
return join('', map { qq(<link type="text/css" rel="stylesheet" href="$_" />) } @css);
}