Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…haracters.
  • Loading branch information...
commit a2c99127b566c91396c48c6f59bc1db676680c6e 1 parent eb14a61
Morgan Schweers authored
6  lib/webrick/httputils.rb
@@ -354,9 +354,9 @@ def _make_regex!(str) /([^#{Regexp.escape(str)}])/n end
354 354
     def _escape(str, regex) str.gsub(regex){ "%%%02X" % $1.ord } end
355 355
     def _unescape(str, regex) str.gsub(regex){ $1.hex.chr } end
356 356
 
357  
-    UNESCAPED = _make_regex(control+space+delims+unwise+nonascii)
358  
-    UNESCAPED_FORM = _make_regex(reserved+control+delims+unwise+nonascii)
359  
-    NONASCII  = _make_regex(nonascii)
  357
+    UNESCAPED = /([\x00-\x20\x7F\<\>\#%"'{}|\\^\[\]`\x80-\xFF])/
  358
+    UNESCAPED_FORM = /([\x00-\x1F;\/?:@&=+\$,\<\>\#%"'{}|\\^\[\]`\x7F\x80-\xFF])/
  359
+    NONASCII  = /([\x80-\xFF])/
360 360
     ESCAPED   = /%([0-9a-fA-F]{2})/
361 361
     UNESCAPED_PCHAR = _make_regex!(unreserved+":@&=+$,")
362 362
 
1  test-mri/test/webrick/test_httputils.rb
@@ -60,6 +60,7 @@ def test_split_header_value
60 60
   end
61 61
 
62 62
   def test_escape
  63
+    assert_equal("/abcdefghijklmnopqrstuvwxyz", escape("/abcdefghijklmnopqrstuvwxyz"))
63 64
     assert_equal("/foo/bar", escape("/foo/bar"))
64 65
     assert_equal("/~foo/bar", escape("/~foo/bar"))
65 66
     assert_equal("/~foo%20bar", escape("/~foo bar"))

0 notes on commit a2c9912

Please sign in to comment.
Something went wrong with that request. Please try again.