Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
It's not recommended to escape ' to '
  • Loading branch information
spastorino committed Aug 13, 2012
commit 538bd3ccfc969da49309e567999b34ed69cdce66
2 changes: 1 addition & 1 deletion lib/cgi/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def CGI::unescape(string,encoding=@@accept_charset)

# The set of special characters and their escaped values
TABLE_FOR_ESCAPE_HTML__ = {
"'" => ''',
"'" => ''',
'&' => '&',
'"' => '"',
'<' => '&lt;',
Expand Down
2 changes: 1 addition & 1 deletion test/cgi/test_cgi_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_cgi_pretty
end

def test_cgi_escapeHTML
assert_equal(CGI::escapeHTML("'&\"><"),"&apos;&amp;&quot;&gt;&lt;")
assert_equal(CGI::escapeHTML("'&\"><"),"&#x27;&amp;&quot;&gt;&lt;")
end

def test_cgi_unescapeHTML
Expand Down
3 changes: 1 addition & 2 deletions test/erb/test_erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def test_with_filename_and_safe_level
end

def test_html_escape
# TODO: &apos; should be changed to &#x27;
assert_equal(" !&quot;\#$%&amp;&apos;()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
assert_equal(" !&quot;\#$%&amp;&#x27;()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
ERB::Util.html_escape(" !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"))

assert_equal("", ERB::Util.html_escape(""))
Expand Down