1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/cgi.rb (read_multipart): exclude blanks from header values.

[ruby-list:44327]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-12-09 03:39:04 +00:00
parent 54f236542d
commit 78cc1c45ee
2 changed files with 10 additions and 5 deletions

View file

@ -1,3 +1,8 @@
Sun Dec 9 12:39:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/cgi.rb (read_multipart): exclude blanks from header values.
[ruby-list:44327]
Sun Dec 9 12:18:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Dec 9 12:18:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_get_path): use the original object if to_path method is * file.c (rb_get_path): use the original object if to_path method is

View file

@ -978,7 +978,7 @@ class CGI
def read_multipart(boundary, content_length) def read_multipart(boundary, content_length)
params = Hash.new([]) params = Hash.new([])
boundary = "--" + boundary boundary = "--" + boundary
quoted_boundary = Regexp.quote(boundary, "n") quoted_boundary = Regexp.quote(boundary)
buf = "" buf = ""
bufsize = 10 * 1024 bufsize = 10 * 1024
boundary_end="" boundary_end=""
@ -1029,13 +1029,13 @@ class CGI
if "--" == $2 if "--" == $2
content_length = -1 content_length = -1
end end
boundary_end = $2.dup boundary_end = $2.dup
"" ""
end end
body.rewind body.rewind
/Content-Disposition:.* filename=(?:"((?:\\.|[^\"])*)"|([^;]*))/ni.match(head) /Content-Disposition:.* filename=(?:"((?:\\.|[^\"\s])*)"|([^;\s]*))/ni.match(head)
filename = ($1 or $2 or "") filename = ($1 or $2 or "")
if /Mac/ni.match(env_table['HTTP_USER_AGENT']) and if /Mac/ni.match(env_table['HTTP_USER_AGENT']) and
/Mozilla/ni.match(env_table['HTTP_USER_AGENT']) and /Mozilla/ni.match(env_table['HTTP_USER_AGENT']) and
@ -1043,7 +1043,7 @@ class CGI
filename = CGI::unescape(filename) filename = CGI::unescape(filename)
end end
/Content-Type: (.*)/ni.match(head) /Content-Type: ([^\s]*)/ni.match(head)
content_type = ($1 or "") content_type = ($1 or "")
(class << body; self; end).class_eval do (class << body; self; end).class_eval do
@ -1052,7 +1052,7 @@ class CGI
define_method(:content_type) {content_type.dup.taint} define_method(:content_type) {content_type.dup.taint}
end end
/Content-Disposition:.* name="?([^\";]*)"?/ni.match(head) /Content-Disposition:.* name="?([^\";\s]*)"?/ni.match(head)
name = ($1 || "").dup name = ($1 || "").dup
if params.has_key?(name) if params.has_key?(name)