Skip to content

Commit

Permalink
* lib/webrick/httputils.rb (WEBrick::HTTPUtils#split_header_value):
Browse files Browse the repository at this point in the history
  reduce backtrack.  based on a fix by Christian Neukirchen
  <chneukirchen AT gmail.com>.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jul 25, 2008
1 parent bf01ea4 commit b2ccd5f
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/webrick/httputils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,8 @@ def normalize_path(path)
ret = path.dup

ret.gsub!(%r{/+}o, '/') # // => /
while ret.sub!(%r{/\.(/|\Z)}o, '/'); end # /. => /
begin # /foo/.. => /foo
match = ret.sub!(%r{/([^/]+)/\.\.(/|\Z)}o){
if $1 == ".."
raise "abnormal path `#{path}'"
else
"/"
end
}
end while match
while ret.sub!(%r'/\.(?:/|\Z)', '/'); end # /. => /
while ret.sub!(%r'/(?!\.\./)[^/]+/\.\.(?:/|\Z)', '/'); end # /foo/.. => /foo

raise "abnormal path `#{path}'" if %r{/\.\.(/|\Z)} =~ ret
ret
Expand Down Expand Up @@ -155,8 +147,8 @@ def parse_header(raw)
module_function :parse_header

def split_header_value(str)
str.scan(/((?:"(?:\\.|[^"])+?"|[^",]+)+)
(?:,\s*|\Z)/xn).collect{|v| v[0] }
str.scan(%r'\G((?:"(?:\\.|[^"])+?"|[^",]+)+)
(?:,\s*|\Z)'xn).flatten
end
module_function :split_header_value

Expand Down

0 comments on commit b2ccd5f

Please sign in to comment.