From e46c89e90fbfa9bd7ccbdcfdbce60dd5968ee0ae Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Fri, 21 Dec 2012 11:14:09 +0100 Subject: [PATCH 1/5] rc2mail now adds some newlines to the HTML mail being sent. --- rc2mail.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rc2mail.pl b/rc2mail.pl index 57613560..055f8eee 100644 --- a/rc2mail.pl +++ b/rc2mail.pl @@ -148,9 +148,12 @@ sub send_file { warn "No content for $title\n" unless $item->{description}; my $link = $item->{link}; my $sub = "$root?action=subscriptions"; - print $fh qq(

Visit $title) + my $text = qq(

Visit $title) . qq( or manage your subscriptions.


) . $item->{description}; + # prevent 501 Syntax error - line too long + $text =~ s/<(p|h[1-6]|[duo]l|pre|li|form|div|blockquote|hr|table|tr)>/\r\n<$1>/gi; + print $fh $text; $fh->close; foreach my $subscriber (@subscribers) { send_mail($subscriber, $title, $fh); From 011953370ab86755ca9da5e36e2351cae5863d7b Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Sun, 6 Jan 2013 18:13:53 +0100 Subject: [PATCH 2/5] Print fractions. --- modules/fractions.pl | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 modules/fractions.pl diff --git a/modules/fractions.pl b/modules/fractions.pl new file mode 100644 index 00000000..0ec557a1 --- /dev/null +++ b/modules/fractions.pl @@ -0,0 +1,60 @@ +# Copyright (C) 2013 Alex Schroeder +# +# 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 . + +$ModulesDescription .= '

fractions.pl, see Fractions

'; + +push(@MyRules, \&FractionsRule); + +# usage: ^1/32 +sub FractionsRule { + if (/\G\^([0-9]+)\/([0-9]+)/cg) { + if ($1 == 1 and $2 == 4) { return "\&x00bc;"; } + elsif ($1 == 1 and $2 == 2) { return "\&x00bd;"; } + elsif ($1 == 3 and $2 == 4) { return "\&x00be;"; } + elsif ($1 == 1 and $2 == 7) { return "\&x2150;"; } + elsif ($1 == 1 and $2 == 9) { return "\&x2151;"; } + elsif ($1 == 1 and $2 == 10) { return "\&x2152;"; } + elsif ($1 == 1 and $2 == 3) { return "\&x2153;"; } + elsif ($1 == 2 and $2 == 3) { return "\&x2154;"; } + elsif ($1 == 1 and $2 == 5) { return "\&x2155;"; } + elsif ($1 == 2 and $2 == 5) { return "\&x2156;"; } + elsif ($1 == 3 and $2 == 5) { return "\&x2157;"; } + elsif ($1 == 4 and $2 == 5) { return "\&x2158;"; } + elsif ($1 == 1 and $2 == 6) { return "\&x2159;"; } + elsif ($1 == 5 and $2 == 6) { return "\&x215a;"; } + elsif ($1 == 1 and $2 == 8) { return "\&x215b;"; } + elsif ($1 == 3 and $2 == 8) { return "\&x215c;"; } + elsif ($1 == 5 and $2 == 8) { return "\&x215d;"; } + elsif ($1 == 7 and $2 == 8) { return "\&x215e;"; } + else { + my $html; + # superscripts + for my $char (split(//, $1)) { + if ($char eq '1') { $html .= "\&x00b9;"; } + elsif ($char eq '2') { $html .= "\&x00b2;"; } + elsif ($char eq '3') { $html .= "\&x00b3;"; } + else { $html .= "\ȇ$char;"; } + } + # fraction slash + $html .= '⁄'; + # subscripts + for my $char (split(//, $2)) { + $html .= "\Ȉ$char;"; + } + return $html; + } + } + return undef; +} From b4b64358263304b0a96d3de7e547e9d0bfd45da9 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Sun, 6 Jan 2013 18:18:16 +0100 Subject: [PATCH 3/5] Fix entities for superscripts and vulgar fractions. --- modules/fractions.pl | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/fractions.pl b/modules/fractions.pl index 0ec557a1..31cb4b7a 100644 --- a/modules/fractions.pl +++ b/modules/fractions.pl @@ -20,31 +20,31 @@ push(@MyRules, \&FractionsRule); # usage: ^1/32 sub FractionsRule { if (/\G\^([0-9]+)\/([0-9]+)/cg) { - if ($1 == 1 and $2 == 4) { return "\&x00bc;"; } - elsif ($1 == 1 and $2 == 2) { return "\&x00bd;"; } - elsif ($1 == 3 and $2 == 4) { return "\&x00be;"; } - elsif ($1 == 1 and $2 == 7) { return "\&x2150;"; } - elsif ($1 == 1 and $2 == 9) { return "\&x2151;"; } - elsif ($1 == 1 and $2 == 10) { return "\&x2152;"; } - elsif ($1 == 1 and $2 == 3) { return "\&x2153;"; } - elsif ($1 == 2 and $2 == 3) { return "\&x2154;"; } - elsif ($1 == 1 and $2 == 5) { return "\&x2155;"; } - elsif ($1 == 2 and $2 == 5) { return "\&x2156;"; } - elsif ($1 == 3 and $2 == 5) { return "\&x2157;"; } - elsif ($1 == 4 and $2 == 5) { return "\&x2158;"; } - elsif ($1 == 1 and $2 == 6) { return "\&x2159;"; } - elsif ($1 == 5 and $2 == 6) { return "\&x215a;"; } - elsif ($1 == 1 and $2 == 8) { return "\&x215b;"; } - elsif ($1 == 3 and $2 == 8) { return "\&x215c;"; } - elsif ($1 == 5 and $2 == 8) { return "\&x215d;"; } - elsif ($1 == 7 and $2 == 8) { return "\&x215e;"; } + if ($1 == 1 and $2 == 4) { return "\¼"; } + elsif ($1 == 1 and $2 == 2) { return "\½"; } + elsif ($1 == 3 and $2 == 4) { return "\¾"; } + elsif ($1 == 1 and $2 == 7) { return "\⅐"; } + elsif ($1 == 1 and $2 == 9) { return "\⅑"; } + elsif ($1 == 1 and $2 == 10) { return "\⅒"; } + elsif ($1 == 1 and $2 == 3) { return "\⅓"; } + elsif ($1 == 2 and $2 == 3) { return "\⅔"; } + elsif ($1 == 1 and $2 == 5) { return "\⅕"; } + elsif ($1 == 2 and $2 == 5) { return "\⅖"; } + elsif ($1 == 3 and $2 == 5) { return "\⅗"; } + elsif ($1 == 4 and $2 == 5) { return "\⅘"; } + elsif ($1 == 1 and $2 == 6) { return "\⅙"; } + elsif ($1 == 5 and $2 == 6) { return "\⅚"; } + elsif ($1 == 1 and $2 == 8) { return "\⅛"; } + elsif ($1 == 3 and $2 == 8) { return "\⅜"; } + elsif ($1 == 5 and $2 == 8) { return "\⅝"; } + elsif ($1 == 7 and $2 == 8) { return "\⅞"; } else { my $html; # superscripts for my $char (split(//, $1)) { - if ($char eq '1') { $html .= "\&x00b9;"; } - elsif ($char eq '2') { $html .= "\&x00b2;"; } - elsif ($char eq '3') { $html .= "\&x00b3;"; } + if ($char eq '1') { $html .= "\¹"; } + elsif ($char eq '2') { $html .= "\²"; } + elsif ($char eq '3') { $html .= "\³"; } else { $html .= "\ȇ$char;"; } } # fraction slash From d9a2db5b8dd6c693250253f3d331672829339fa0 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Mon, 7 Jan 2013 13:51:39 +0100 Subject: [PATCH 4/5] Added support for sub and sup tags. --- modules/bbcode.pl | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/modules/bbcode.pl b/modules/bbcode.pl index 96f0fc08..a8832608 100644 --- a/modules/bbcode.pl +++ b/modules/bbcode.pl @@ -1,17 +1,16 @@ -# Copyright (C) 2007, 2008 Alex Schroeder +# Copyright (C) 2007, 2008, 2013 Alex Schroeder # -# 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 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, see . +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . $ModulesDescription .= '

bbcode.pl, see bbCode Extension

'; @@ -37,6 +36,10 @@ sub bbCodeRule { . qq{font-style: normal;"}); } elsif ($tag eq 's' or $tag eq 'strike') { return AddHtmlEnvironment('del'); } + elsif ($tag eq 'sub') { + return AddHtmlEnvironment('sub'); } + elsif ($tag eq 'sup') { + return AddHtmlEnvironment('sup'); } elsif ($tag eq 'color') { return AddHtmlEnvironment('em', qq{style="color: $option; } . qq{font-style: normal;"}); } @@ -96,7 +99,7 @@ sub bbCodeRule { %translate = qw{b b i i u em color em size em font span url a quote blockquote h1 h1 h2 h2 h3 h3 h4 h4 h5 h5 h6 h6 center div left div right div list ul - s del strike del highlight strong}; + s del strike del sub sub sup sup highlight strong}; # closing a block level element closes all elements if ($bbBlock eq $translate{$tag}) { /\G([ \t]*\n)*/cg; # eat whitespace after closing block level element From e188665a9b0ca5ae9b1423f8543764e3a6d79fe5 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Thu, 10 Jan 2013 14:25:56 +0100 Subject: [PATCH 5/5] No longer validate the UTF-8 from rc.log files in GetRcLinesFor. If the rc.log file contained invalid UTF-8, this would fill the server logs with thousands of warnings. There is nothing we can do about these (they probably originated from an older copy of the script). Therefore, <:utf8 is now used instead of <:encoding(UTF-8). --- wiki.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wiki.pl b/wiki.pl index f0647372..d6ef7506 100755 --- a/wiki.pl +++ b/wiki.pl @@ -1586,7 +1586,8 @@ sub GetRcLinesFor { rcclusteronly rcfilteronly match lang followup); # parsing and filtering my @result = (); - open(F, '<:encoding(UTF-8)', $file) or return (); + # using :utf8 instead of :encoding(utf-8) to avoid validation and warnings on corrupt files :( + open(F, '<:utf8', $file) or return (); while (my $line = ) { chomp($line); my ($ts, $id, $minor, $summary, $host, $username, $revision,