mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@18220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
65aa393ae7
commit
1181a092af
2 changed files with 10 additions and 12 deletions
|
@ -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>
|
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.
|
* test/ruby/enc/test_koi8.rb: move from test/ruby/test_koi8.rb.
|
||||||
|
|
|
@ -23,16 +23,8 @@ module WEBrick
|
||||||
ret = path.dup
|
ret = path.dup
|
||||||
|
|
||||||
ret.gsub!(%r{/+}o, '/') # // => /
|
ret.gsub!(%r{/+}o, '/') # // => /
|
||||||
while ret.sub!(%r{/\.(/|\Z)}o, '/'); end # /. => /
|
while ret.sub!(%r'/\.(?:/|\Z)', '/'); end # /. => /
|
||||||
begin # /foo/.. => /foo
|
while ret.sub!(%r'/(?!\.\./)[^/]+/\.\.(?:/|\Z)', '/'); end # /foo/.. => /foo
|
||||||
match = ret.sub!(%r{/([^/]+)/\.\.(/|\Z)}o){
|
|
||||||
if $1 == ".."
|
|
||||||
raise "abnormal path `#{path}'"
|
|
||||||
else
|
|
||||||
"/"
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end while match
|
|
||||||
|
|
||||||
raise "abnormal path `#{path}'" if %r{/\.\.(/|\Z)} =~ ret
|
raise "abnormal path `#{path}'" if %r{/\.\.(/|\Z)} =~ ret
|
||||||
ret
|
ret
|
||||||
|
@ -155,8 +147,8 @@ module WEBrick
|
||||||
module_function :parse_header
|
module_function :parse_header
|
||||||
|
|
||||||
def split_header_value(str)
|
def split_header_value(str)
|
||||||
str.scan(/((?:"(?:\\.|[^"])+?"|[^",]+)+)
|
str.scan(%r'\G((?:"(?:\\.|[^"])+?"|[^",]+)+)
|
||||||
(?:,\s*|\Z)/xn).collect{|v| v[0] }
|
(?:,\s*|\Z)'xn).flatten
|
||||||
end
|
end
|
||||||
module_function :split_header_value
|
module_function :split_header_value
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue