summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/webrick/httputils.rb16
2 files changed, 10 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 066ebdf3b2..c56e1f8be7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Jul 25 23:35:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils#split_header_value):
+ reduce backtrack. based on a fix by Christian Neukirchen
+ <chneukirchen AT gmail.com>.
+
Fri Jul 25 21:55:38 2008 Yusuke Endoh <mame@tsg.ne.jp>
* test/ruby/enc/test_koi8.rb: move from test/ruby/test_koi8.rb.
diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb
index b9bd5ae91d..f921364786 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