summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-25 14:35:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-25 14:35:21 +0000
commit23dc9cdb0341af9c07e245126b403ee857c9aa1e (patch)
treecf511b2a7b2b35598ad2c028e1be724f11133b15 /lib
parent655345dfdfb98d108ab6ad7d2111c906eaec0d8e (diff)
downloadruby-23dc9cdb0341af9c07e245126b403ee857c9aa1e.tar.gz
ruby-23dc9cdb0341af9c07e245126b403ee857c9aa1e.tar.xz
ruby-23dc9cdb0341af9c07e245126b403ee857c9aa1e.zip
* lib/webrick/httputils.rb (WEBrick::HTTPUtils#split_header_value):
reduce backtrack. based on a fix by Christian Neukirchen <chneukirchen AT gmail.com>. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/webrick/httputils.rb16
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb
index b9bd5ae91..f92136478 100644
--- a/lib/webrick/httputils.rb
+++ b/lib/webrick/httputils.rb
@@ -23,16 +23,8 @@ module WEBrick
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
@@ -155,8 +147,8 @@ module WEBrick
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