Remove absolute sizes when logged out, but not when logged in.

        Patch by kareila. 

diffs (72 lines):

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" );
 
 
 }
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to