Skip Menu |

This queue is for tickets about the HTML-Sanitizer CPAN distribution.

Report information
The Basics
Id: 35557
Status: new
Priority: 0/
Queue: HTML-Sanitizer

People
Owner: Nobody in particular
Requestors: stas [...] stason.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.04
Fixed in: (no value)



Subject: code refs don't work
David, using code refs doesn't seem to work $safe->permit( p => sub { 1 } ); Not a HASH reference: tried to fix that --- Sanitizer.pm 2003-08-05 16:25:09.000000000 -0700 +++ Sanitizer.pm 2008-04-30 15:59:02.000000000 -0700 @@ -52,8 +52,10 @@ if (UNIVERSAL::isa($attrs, "HTML::Element")) { $self->{_rules}->{$element} = $attrs; - } - + } + elsif (ref $attrs eq 'CODE') { + $self->{_rules}->{$element} = $attrs; + } elsif (ref $attrs) { $attrs = array2hash($attrs); foreach (keys %{$attrs}) { but it then next fails with a similar problem if it sees <p align...> for example Not a HASH reference at /usr/lib/perl5/site_perl/5.10.0/HTML/Sanitizer.pm line 309. This seems to fix that one as well: --- Sanitizer.pm 2003-08-05 16:25:09.000000000 -0700 +++ Sanitizer.pm 2008-04-30 16:03:20.000000000 -0700 @@ -52,8 +52,10 @@ if (UNIVERSAL::isa($attrs, "HTML::Element")) { $self->{_rules}->{$element} = $attrs; - } - + } + elsif (ref $attrs eq 'CODE') { + $self->{_rules}->{$element} = $attrs; + } elsif (ref $attrs) { $attrs = array2hash($attrs); foreach (keys %{$attrs}) { @@ -304,7 +306,7 @@ ATTR_SEARCH: for my $o ($tag, "_", "*") { if (ref $self->{_rules}->{$o}) { for my $i ($attr, '*') { - if (exists($self->{_rules}->{$o}->{$i})) { + if (ref($self->{_rules}->{$o}) eq 'HASH' and exists $self->{_rules}->{$o}->{$i}) { debug " found match in $o/$i"; $r = $self->{_rules}->{$o}->{$i}; last ATTR_SEARCH;