3 # Tests that the following translations take place, and none other:
5 # & => & (aka &)
6 # < => < (aka <)
7 # > => > (aka >)
8 # ' => ' (aka ')
9 # " => " (aka ")
11 # Further tests that already-escaped things are not further escaped.
13 # Escapes are defined in the XML spec:
14 # http://www.w3.org/TR/2006/REC-xml11-20060816/#dt-escape
19 'x > 3' => 'x > 3',
20 'x < 3' => 'x < 3',
21 '< 3 >' => '< 3 >',
23 "he’s" => "he’s", # MS "smart" quotes don't get escaped (single)
24 '"his"' => '"his"',
25 '‘his’' => '‘his’', # MS "smart" quotes don't get escaped (single)
26 '“his”' => '“his”', # MS "smart" quotes don't get escaped (double)
28 '1&2' => '1&2',
29 '1&2' => '1&2',
30 '1& 2' => '1&amp 2',
31 '1& 2' => '1&#38 2',
35 'Œ' => 'Œ',
37 '&no_go;' => '&no_go;',
39 'This ſoftware has ſome bugs' => 'This ſoftware has ſome bugs', # RT 18568
42 $tests = keys(%translations) + 1;
45 use Test::More tests => $tests;
49 use_ok('HTML::Element');
52 foreach my $orig (keys %translations) {
54 HTML::Element::_xml_escape($new);
55 is($new,$translations{$orig},"Properly escaped: $orig");