Skip to content

Commit

Permalink
Make WEBrick::HTTPUtils.escape not unnecessarily escape 'v' and 'z' c…
Browse files Browse the repository at this point in the history
…haracters.
  • Loading branch information
cyberfox committed Jul 2, 2011
1 parent eb14a61 commit a2c9912
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/webrick/httputils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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+":@&=+$,")

Expand Down
1 change: 1 addition & 0 deletions test-mri/test/webrick/test_httputils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit a2c9912

Please sign in to comment.