[dw-free] http://bugs.dwscoalition.org/show_bug.cgi?id=3438
[commit: http://hg.dwscoalition.org/dw-free/rev/5b112ff9ae13]
http://bugs.dwscoalition.org/show_bug.cgi?id=3438
Remove absolute sizes when logged out, but not when logged in.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3438
Remove absolute sizes when logged out, but not when logged in.
Patch by
Files modified:
- cgi-bin/LJ/CleanHTML.pm
- t/clean-comment.t
--------------------------------------------------------------------------------
diff -r 3b8289e9abc8 -r 5b112ff9ae13 cgi-bin/LJ/CleanHTML.pm
--- a/cgi-bin/LJ/CleanHTML.pm Tue Feb 15 11:32:14 2011 +0800
+++ b/cgi-bin/LJ/CleanHTML.pm Tue Feb 15 11:32:15 2011 +0800
@@ -1571,7 +1571,7 @@ sub clean_comment
'nocss' => $opts->{'nocss'},
'textonly' => $opts->{'textonly'} ? 1 : 0,
'remove_positioning' => 1,
- 'remove_abs_sizes' => 1,
+ 'remove_abs_sizes' => $opts->{anon_comment},
});
}
diff -r 3b8289e9abc8 -r 5b112ff9ae13 t/clean-comment.t
--- a/t/clean-comment.t Tue Feb 15 11:32:14 2011 +0800
+++ b/t/clean-comment.t Tue Feb 15 11:32:15 2011 +0800
@@ -2,7 +2,7 @@
use strict;
use Test::More;
-plan tests => 16;
+plan tests => 19;
use lib "$ENV{LJHOME}/cgi-bin";
require 'ljlib.pl';
@@ -59,22 +59,42 @@ ok($orig_comment =~/^$clean_comment$/, "
$clean->({ remove_positioning => 1 });
ok($orig_comment =~ /^$clean_comment$/, "Padding not removed; of reasonable size.");
-note( "Clean absolute sizes" );
+note( "Remove absolute sizes when logged out" );
{
$orig_comment = qq{<span style="font-size: larger">foo</span>};
$clean_comment = qq{<span style="font-size: larger">foo</span>};
+ $clean->( { anon_comment => 1 } );
+ is( $orig_comment, $clean_comment, "Retain relative font sizes" );
+
+ $orig_comment = qq{<span style="font-size: 10px ">foo</span>};
+ $clean_comment = qq{<span style="">foo</span>};
+ $clean->( { anon_comment => 1 } );
+ is( $orig_comment, $clean_comment, "Strip absolute font sizes" );
+
+ $orig_comment = qq{<span style="font-size:0.2em; font-weight: bold">foo</span>};
+ $clean_comment = qq{<span style=" font-weight: bold">foo</span>};
+ $clean->( { anon_comment => 1 } );
+ is( $orig_comment, $clean_comment, "Strip absolute font sizes" );
+
+
+}
+
+note( "Don't remove absolute sizes when logged in" );
+{
+ $orig_comment = qq{<span style="font-size: larger">foo</span>};
+ $clean_comment = $orig_comment;
$clean->();
is( $orig_comment, $clean_comment, "Retain relative font sizes" );
$orig_comment = qq{<span style="font-size: 10px ">foo</span>};
- $clean_comment = qq{<span style="">foo</span>};
+ $clean_comment = $orig_comment;
$clean->();
- is( $orig_comment, $clean_comment, "Strip absolute font sizes" );
+ is( $orig_comment, $clean_comment, "Retain absolute font sizes" );
$orig_comment = qq{<span style="font-size:0.2em; font-weight: bold">foo</span>};
- $clean_comment = qq{<span style=" font-weight: bold">foo</span>};
+ $clean_comment = $orig_comment;
$clean->();
- is( $orig_comment, $clean_comment, "Strip absolute font sizes" );
+ is( $orig_comment, $clean_comment, "Retain absolute font sizes" );
}
--------------------------------------------------------------------------------
