use File::Glob ();
-
-
my $IN_SCOPE = 0;
sub import {
$IN_SCOPE = 1;
}
+sub sanitize {
+ map { # string == text -> HTML, scalarref == raw HTML, other == passthrough
+ ref($_)
+ ? (ref $_ eq 'SCALAR' ? $$_ : $_)
+ : do { local $_ = $_; # copy
+ s/&/&/g; s/"/"/g; s/</</g; s/>/>/g; $_;
+ }
+ } @_
+}
+
sub _find_tags { shift; @_ }
sub _find_target {
sub quux {
use HTML::Tags;
- <html>, <body id="spoon">, \"YAY", </body>, </html>;
+ <html>, <body id="spoon">, "YAY", </body>, </html>;
}
}
is(
- join(', ', map ${$_}, Foo::foo()),
+ join(', ', XML::Tags::sanitize Foo::foo()),
'<one>, <two>, <three>',
'open tags ok'
);
ok(!eval { Foo::bar(); 1 }, 'Death on use of unimported tag');
is(
- join(', ', map ${$_}, Foo::baz()),
+ join(', ', XML::Tags::sanitize Foo::baz()),
'</bar>',
'close tag ok'
);
is(
- join('', map ${$_}, Foo::quux),
+ join('', XML::Tags::sanitize Foo::quux),
'<html><body id="spoon">YAY</body></html>',
'HTML tags ok'
);