Skip to content

Commit 8c6c0af

Browse files
author
Jeff Fearn
committed
fix _xml_escape method name so sub-classes still work as expected
fix comment fooling Module::ExtractUse
1 parent bca3ffd commit 8c6c0af

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/HTML/Element.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,8 @@ sub delete_content {
12631263
# will keep calls to detach() from trying to uselessly filter
12641264
# the list (as they won't be able to see it once it's been
12651265
# deleted)
1266-
|| return ( $_[0] ) # in case of no content
1266+
|| return ( $_[0] )
1267+
# in case of no content
12671268
},
12681269
0
12691270

@@ -2095,7 +2096,7 @@ sub _xml_escape_text {
20952096
return;
20962097
}
20972098

2098-
sub _xml_escape_attr {
2099+
sub _xml_escape {
20992100

21002101
# DESTRUCTIVE (a.k.a. "in-place")
21012102
# In addition to other escapes, also escape apostrophe and double-quote
@@ -2350,7 +2351,7 @@ sub starttag_XML {
23502351
# Hm -- what to do if val is undef?
23512352
# I suppose that shouldn't ever happen.
23522353
next if !defined( $val = $self->{$_} ); # or ref $val;
2353-
_xml_escape_attr($val);
2354+
_xml_escape($val);
23542355
$tag .= qq{ $_="$val"};
23552356
}
23562357
@_ == 3 ? "$tag />" : "$tag>";

t/escape.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,24 @@ $HTML::Element::encoded_content = 1;
6161

6262
foreach my $orig ( keys %translations ) {
6363
my $new = $orig;
64-
HTML::Element::_xml_escape_attr($new);
64+
HTML::Element::_xml_escape($new);
6565
is( $new, $translations{$orig}, "Properly escaped: $orig" );
6666
}
6767

6868
# test that multiple runs don't change the value
6969
my $test_orig = '&foo; &bar;';
7070
my $test_str = $test_orig;
71-
HTML::Element::_xml_escape_attr($test_str);
71+
HTML::Element::_xml_escape($test_str);
7272
is( $test_str, $test_orig, "Multiple runs 1" );
73-
HTML::Element::_xml_escape_attr($test_str);
73+
HTML::Element::_xml_escape($test_str);
7474
is( $test_str, $test_orig, "Multiple runs 2" );
75-
HTML::Element::_xml_escape_attr($test_str);
75+
HTML::Element::_xml_escape($test_str);
7676
is( $test_str, $test_orig, "Multiple runs 3" );
7777

7878
# test default path, always encode '&'
7979
$HTML::Element::encoded_content = 0;
8080
$test_str = $test_orig;
8181
my $test_expected = '&foo; &bar;';
82-
HTML::Element::_xml_escape_attr($test_str);
82+
HTML::Element::_xml_escape($test_str);
8383
is( $test_str, $test_expected, "Default encode" );
8484

0 commit comments

Comments
 (0)