From c451c56b10be59e905667c93b167f05bb9e4f50b Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 27 Mar 2004 12:43:02 +0000 Subject: [PATCH] * (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 --- ChangeLog | 4 ++++ lib/open-uri.rb | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c86a168a4d..6988d0c814 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 c6bfd7a509..84acdb9984 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] }