Permalink
Browse files

Make WEBrick::HTTPUtils.escape not unnecessarily escape 'v' and 'z' c…

…haracters.
  • Loading branch information...
1 parent eb14a61 commit a2c99127b566c91396c48c6f59bc1db676680c6e @cyberfox committed May 1, 2011
Showing with 4 additions and 3 deletions.
  1. +3 −3 lib/webrick/httputils.rb
  2. +1 −0 test-mri/test/webrick/test_httputils.rb
View
@@ -354,9 +354,9 @@ def _make_regex!(str) /([^#{Regexp.escape(str)}])/n end
def _escape(str, regex) str.gsub(regex){ "%%%02X" % $1.ord } end
def _unescape(str, regex) str.gsub(regex){ $1.hex.chr } end
- UNESCAPED = _make_regex(control+space+delims+unwise+nonascii)
- UNESCAPED_FORM = _make_regex(reserved+control+delims+unwise+nonascii)
- NONASCII = _make_regex(nonascii)
+ UNESCAPED = /([\x00-\x20\x7F\<\>\#%"'{}|\\^\[\]`\x80-\xFF])/
+ UNESCAPED_FORM = /([\x00-\x1F;\/?:@&=+\$,\<\>\#%"'{}|\\^\[\]`\x7F\x80-\xFF])/
+ NONASCII = /([\x80-\xFF])/
ESCAPED = /%([0-9a-fA-F]{2})/
UNESCAPED_PCHAR = _make_regex!(unreserved+":@&=+$,")
@@ -60,6 +60,7 @@ def test_split_header_value
end
def test_escape
+ assert_equal("/abcdefghijklmnopqrstuvwxyz", escape("/abcdefghijklmnopqrstuvwxyz"))
assert_equal("/foo/bar", escape("/foo/bar"))
assert_equal("/~foo/bar", escape("/~foo/bar"))
assert_equal("/~foo%20bar", escape("/~foo bar"))

0 comments on commit a2c9912

Please sign in to comment.