From be7fc487ab5d856403eb2dfcaea2b87ad30e8d03 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 27 Mar 2004 12:43:02 +0000 Subject: * (lib/open-uri.rb): permit extra semicolon in content-type field. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/open-uri.rb | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b02a41bb7..e9d1d8bc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Mar 27 21:40:41 2004 Tanaka Akira + + * (lib/open-uri.rb): permit extra semicolon in content-type field. + Sat Mar 27 10:40:48 2004 Tanaka Akira * (lib/pp.rb, lib/prettyprint.rb): define seplist in PP::PPMethods diff --git a/lib/open-uri.rb b/lib/open-uri.rb index c6bfd7a50..84acdb998 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -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] } -- cgit