Tweak regexes to be more efficient.
Patch by kareila.
diffs (39 lines):
diff -r 95500b0d38f5 -r 14f68f3391dc cgi-bin/ljtextutil.pl
--- a/cgi-bin/ljtextutil.pl Wed Dec 01 11:16:37 2010 +0800
+++ b/cgi-bin/ljtextutil.pl Wed Dec 01 11:19:22 2010 +0800
@@ -207,7 +207,8 @@ sub ejs
sub ejs
{
my $a = $_[0];
- $a =~ s/[\"\'\\]/\\$&/g;
+ # use zero-width lookahead to insert a backslash where needed
+ $a =~ s/(?=[\"\'\\])/\\/g;
$a =~ s/"/\\"/g;
$a =~ s/\r?\n/\\n/gs;
$a =~ s/\r//gs;
diff -r 95500b0d38f5 -r 14f68f3391dc htdocs/community/moderate.bml
--- a/htdocs/community/moderate.bml Wed Dec 01 11:16:37 2010 +0800
+++ b/htdocs/community/moderate.bml Wed Dec 01 11:19:22 2010 +0800
@@ -377,10 +377,6 @@ body<=
} else {
$event =~ s/\r//g;
}
- my $etime = sprintf("%04d-%02d-%02d %02d:%02d",
- $req->{'year'}, $req->{'mon'},
- $req->{'day'}, $req->{'hour'},
- $req->{'min'});
my $subject = $req->{'subject'};
my $props = $req->{'props'};
my $up = LJ::load_user($req->{'username'});
@@ -439,7 +435,10 @@ body<=
'userlink' =>
LJ::ljuser($up->{'user'}),
'commlink' => "<?ljcomm
$c->{'user'} ljcomm?>" });
- $etime =~ s!(\d\d\d\d)-(\d\d)-(\d\d)!LJ::date_to_view_links($c, $&)!e;
+ my $datestr = sprintf( "%04d-%02d-%02d", $req->{year}, $req->{mon},
$req->{day} );
+ my $etime = sprintf( "%s %02d:%02d",
+ LJ::date_to_view_links( $c, $datestr ),
+ $req->{hour}, $req->{min} );
$ret .= "<br /><font size='-1'>@ $etime</font>";
$ret .= "</td></tr></table>";
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog