[dw-free] http://bugs.dwscoalition.org/show_bug.cgi?id=3514
[commit: http://hg.dwscoalition.org/dw-free/rev/0ee92a93a23f]
http://bugs.dwscoalition.org/show_bug.cgi?id=3514
Clean out the data attribute for all tags (add tests)
Patch by
fu.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3514
Clean out the data attribute for all tags (add tests)
Patch by
Files modified:
- cgi-bin/LJ/CleanHTML.pm
- t/clean-embed.t
--------------------------------------------------------------------------------
diff -r d59a48c9a62d -r 0ee92a93a23f cgi-bin/LJ/CleanHTML.pm
--- a/cgi-bin/LJ/CleanHTML.pm Tue Mar 29 10:50:38 2011 +0800
+++ b/cgi-bin/LJ/CleanHTML.pm Tue Mar 29 10:50:42 2011 +0800
@@ -655,8 +655,8 @@ sub clean
next;
}
- if ($attr eq "data") {
- delete $hash->{$attr} unless $tag eq "object";
+ if ( $attr eq "data" ) {
+ delete $hash->{$attr};
next;
}
diff -r d59a48c9a62d -r 0ee92a93a23f t/clean-embed.t
--- a/t/clean-embed.t Tue Mar 29 10:50:38 2011 +0800
+++ b/t/clean-embed.t Tue Mar 29 10:50:42 2011 +0800
@@ -1,7 +1,7 @@
# -*-perl-*-
use strict;
-use Test::More tests => 142;
+use Test::More tests => 143;
use lib "$ENV{LJHOME}/cgi-bin";
require 'ljlib.pl';
@@ -48,6 +48,11 @@ note( "Testing clean_embed (we provide t
$clean->();
is( $orig_post, $clean_post, "<object> and <embed> tags" );
+ note( "object tag with data attribute" );
+ $orig_post = qq{<object width="123" data="abc" height="456"></object>};
+ $clean_post = qq{<object width="123" height="456"></object>};
+ $clean->();
+ is( $orig_post, $clean_post, "Drop the data attribute" );
note("script tag");
$orig_post = qq{<object><script>bar</script></object>};
--------------------------------------------------------------------------------
