ruby-changes:6831
From: shyouhei <ko1@a...>
Date: Mon, 4 Aug 2008 14:18:20 +0900 (JST)
Subject: [ruby-changes:6831] Ruby:r18347 (ruby_1_8_6): merge revision(s) 18220:
shyouhei 2008-08-04 14:18:09 +0900 (Mon, 04 Aug 2008) New Revision: 18347 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18347 Log: merge revision(s) 18220: * lib/webrick/httputils.rb (WEBrick::HTTPUtils#split_header_value): reduce backtrack. based on a fix by Christian Neukirchen <chneukirchen AT gmail.com>. Modified files: branches/ruby_1_8_6/ChangeLog branches/ruby_1_8_6/lib/webrick/httputils.rb branches/ruby_1_8_6/version.h Index: ruby_1_8_6/ChangeLog =================================================================== --- ruby_1_8_6/ChangeLog (revision 18346) +++ ruby_1_8_6/ChangeLog (revision 18347) @@ -1,3 +1,9 @@ +Mon Aug 4 14:15:58 2008 Nobuyoshi Nakada <nobu@r...> + + * lib/webrick/httputils.rb (WEBrick::HTTPUtils#split_header_value): + reduce backtrack. based on a fix by Christian Neukirchen + <chneukirchen AT gmail.com>. + Mon Aug 4 14:10:01 2008 Nobuyoshi Nakada <nobu@r...> * regex.c (xmalloc, xrealloc, xfree): not to use ruby managed memory. Index: ruby_1_8_6/version.h =================================================================== --- ruby_1_8_6/version.h (revision 18346) +++ ruby_1_8_6/version.h (revision 18347) @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2008-08-04" #define RUBY_VERSION_CODE 186 #define RUBY_RELEASE_CODE 20080804 -#define RUBY_PATCHLEVEL 284 +#define RUBY_PATCHLEVEL 285 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 Index: ruby_1_8_6/lib/webrick/httputils.rb =================================================================== --- ruby_1_8_6/lib/webrick/httputils.rb (revision 18346) +++ ruby_1_8_6/lib/webrick/httputils.rb (revision 18347) @@ -23,16 +23,8 @@ 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 @@ -154,8 +146,8 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/