Skip to content

Commit

Permalink
Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
Browse files Browse the repository at this point in the history
  • Loading branch information
distler committed Feb 18, 2011
2 parents 363d725 + 3843fa6 commit f9628a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
18 changes: 5 additions & 13 deletions lib/instiki_stringsupport.rb
Expand Up @@ -2329,24 +2329,16 @@ def unescapeHTML
when /\Aquot\z/ni then '"'
when /\Aapos\z/ni then "'"
when /\A#0*(\d+)\z/n then
if Integer($1) < 256
Integer($1).chr
if Integer($1) < 1114111
[Integer($1)].pack("U")
else
if Integer($1) < 1114111
[Integer($1)].pack("U")
else
"&##{$1};"
end
"&##{$1};"
end
when /\A#x([0-9a-f]+)\z/ni then
if $1.hex < 256
if $1.hex < 1114111
[$1.hex].pack("U")
else
if $1.hex < 1114111
[$1.hex].pack("U")
else
"&#x#{$1};"
end
"&#x#{$1};"
end
else
"&#{match};"
Expand Down
6 changes: 3 additions & 3 deletions test/unit/sanitizer_test.rb
Expand Up @@ -23,9 +23,9 @@ def check_sanitization(input, htmloutput, xhtmloutput, rexmloutput)
end

def test_sanitize_named_entities
input = '<p>Greek &phis; &phi;, double-struck &Aopf;, numeric &#x1D538; &#8279;, uppercase &TRADE; &LT;</p>'
output = "<p>Greek \317\225 \317\206, double-struck \360\235\224\270, numeric \360\235\224\270 \342\201\227, uppercase \342\204\242 &lt;</p>"
output2 = "<p>Greek \317\225 \317\206, double-struck \360\235\224\270, numeric &#x1D538; &#8279;, uppercase \342\204\242 &lt;</p>"
input = '<p>Greek &phis; &phi;, double-struck &Aopf;, numeric &nbsp; &#xA0; &#x1D538; &#8279;, uppercase &TRADE; &LT;</p>'
output = "<p>Greek \317\225 \317\206, double-struck \360\235\224\270, numeric \302\240 \302\240 \360\235\224\270 \342\201\227, uppercase \342\204\242 &lt;</p>"
output2 = "<p>Greek \317\225 \317\206, double-struck \360\235\224\270, numeric \302\240 &#xA0; &#x1D538; &#8279;, uppercase \342\204\242 &lt;</p>"
check_sanitization(input, output, output, output)
assert_equal(output2, input.to_utf8.as_bytes)
end
Expand Down

0 comments on commit f9628a3

Please sign in to comment.