aboutsummaryrefslogtreecommitdiffstats
path: root/lib/webrick/htmlutils.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-20 01:40:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-20 01:40:30 +0000
commit88bcccd4333fee37e90dc524ccb7cc20745e0332 (patch)
tree364306a4580ce96511ce69f3e49ee4e259948f94 /lib/webrick/htmlutils.rb
parentbcddf03238140babb6112d289fd88e118390d4ce (diff)
downloadruby-88bcccd4333fee37e90dc524ccb7cc20745e0332.tar.gz
webrick: fix non-ascii escape bugs
* lib/webrick/htmlutils.rb (WEBrick::HTMLUtils#escape): replace HTML meta chars even in non-ascii string. [Bug #8425] [ruby-core:55052] * lib/webrick/httputils.rb (WEBrick::HTTPUtils#{_escape,_unescape}): fix %-escape encodings. [Bug #8425] [ruby-core:55052] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/htmlutils.rb')
-rw-r--r--lib/webrick/htmlutils.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/webrick/htmlutils.rb b/lib/webrick/htmlutils.rb
index ed901f1ce2..4cb3d0d7f6 100644
--- a/lib/webrick/htmlutils.rb
+++ b/lib/webrick/htmlutils.rb
@@ -15,12 +15,13 @@ module WEBrick
# Escapes &, ", > and < in +string+
def escape(string)
- str = string ? string.dup : ""
+ return "" unless string
+ str = string.b
str.gsub!(/&/n, '&amp;')
str.gsub!(/\"/n, '&quot;')
str.gsub!(/>/n, '&gt;')
str.gsub!(/</n, '&lt;')
- str
+ str.force_encoding(string.encoding)
end
module_function :escape