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

* (lib/open-uri.rb): permit extra semicolon in content-type field.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2004-03-27 12:43:02 +00:00
parent 4d664a098d
commit c451c56b10
2 changed files with 7 additions and 2 deletions

View file

@ -1,3 +1,7 @@
Sat Mar 27 21:40:41 2004 Tanaka Akira <akr@m17n.org>
* (lib/open-uri.rb): permit extra semicolon in content-type field.
Sat Mar 27 10:40:48 2004 Tanaka Akira <akr@m17n.org>
* (lib/pp.rb, lib/prettyprint.rb): define seplist in PP::PPMethods

View file

@ -282,11 +282,12 @@ module OpenURI
def content_type_parse # :nodoc:
v = @meta['content-type']
if v && %r{\A#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?/(#{RE_TOKEN})#{RE_LWS}?(#{RE_PARAMETERS})\z}o =~ v
# The last (?:;#{RE_LWS}?)? matches extra ";" which is not permitted by RFC2045.
if v && %r{\A#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?/(#{RE_TOKEN})#{RE_LWS}?(#{RE_PARAMETERS})(?:;#{RE_LWS}?)?\z}no =~ v
type = $1.downcase
subtype = $2.downcase
parameters = []
$3.scan(/;#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?=#{RE_LWS}?(?:(#{RE_TOKEN})|(#{RE_QUOTED_STRING}))/o) {|att, val, qval|
$3.scan(/;#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?=#{RE_LWS}?(?:(#{RE_TOKEN})|(#{RE_QUOTED_STRING}))/no) {|att, val, qval|
val = qval.gsub(/[\r\n\t !#-\[\]-~\x80-\xff]+|(\\[\x00-\x7f])/) { $1 ? $1[1,1] : $& } if qval
parameters << [att.downcase, val]
}