use strict; use warnings; use Test::More tests => 21; use HTML::FormFu::Util qw( literal remove_xml_attribute xml_escape ); { # remove literal from literal my %attr = ( key => literal("{key}, "{key}, "{key}, "{key}, "{key}, "{key}, "" ); } { # remove string from literal my %attr = ( key => literal("<foo <bar <foo <bar <foo") ); is( xml_escape( \%attr )->{key}, "<foo <bar <foo <bar <foo" ); remove_xml_attribute( \%attr, "key", "{key}, "<bar <foo <bar <foo" ); remove_xml_attribute( \%attr, "key", "{key}, "<bar <bar <foo" ); remove_xml_attribute( \%attr, "key", "{key}, "<bar <bar" ); remove_xml_attribute( \%attr, "key", "{key}, "<bar" ); remove_xml_attribute( \%attr, "key", "{key}, "" ); } { # remove string from string my %attr = ( key => "{key}, "<foo <bar <foo <bar <foo" ); remove_xml_attribute( \%attr, "key", "{key}, "<bar <foo <bar <foo" ); remove_xml_attribute( \%attr, "key", "{key}, "<bar <bar <foo" ); remove_xml_attribute( \%attr, "key", "{key}, "<bar <bar" ); } { # remove literal from string my %attr = ( key => "{key}, "<foo <bar <foo <bar <foo" ); remove_xml_attribute( \%attr, "key", literal "<foo" ); is( xml_escape( \%attr )->{key}, "<bar <foo <bar <foo" ); remove_xml_attribute( \%attr, "key", literal "<foo" ); is( xml_escape( \%attr )->{key}, "<bar <bar <foo" ); remove_xml_attribute( \%attr, "key", literal "<foo" ); is( xml_escape( \%attr )->{key}, "<bar <bar" ); # ... remove a string remove_xml_attribute( \%attr, "key", '{key}, "<bar" ); }