From d15b38d944c27cb627741206d8adf285153a4df2 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 18 Feb 2022 09:45:13 +0100 Subject: [ruby/open-uri] Avoid busting the global constant cache `Object#extend(mod)` bump the global constant cache if the module has constants of its own. So by moving these constants outside of `Meta` we avoid bumping the cache. https://github.com/ruby/open-uri/commit/363c399bac --- lib/open-uri.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/open-uri.rb b/lib/open-uri.rb index cb9c3aa505..36bc3e7266 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -410,6 +410,13 @@ module OpenURI end end + # :stopdoc: + RE_LWS = /[\r\n\t ]+/n + RE_TOKEN = %r{[^\x00- ()<>@,;:\\"/\[\]?={}\x7f]+}n + RE_QUOTED_STRING = %r{"(?:[\r\n\t !#-\[\]-~\x80-\xff]|\\[\x00-\x7f])*"}n + RE_PARAMETERS = %r{(?:;#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?=#{RE_LWS}?(?:#{RE_TOKEN}|#{RE_QUOTED_STRING})#{RE_LWS}?)*}n + # :startdoc: + # Mixin for holding meta-information. module Meta def Meta.init(obj, src=nil) # :nodoc: @@ -487,13 +494,6 @@ module OpenURI end end - # :stopdoc: - RE_LWS = /[\r\n\t ]+/n - RE_TOKEN = %r{[^\x00- ()<>@,;:\\"/\[\]?={}\x7f]+}n - RE_QUOTED_STRING = %r{"(?:[\r\n\t !#-\[\]-~\x80-\xff]|\\[\x00-\x7f])*"}n - RE_PARAMETERS = %r{(?:;#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?=#{RE_LWS}?(?:#{RE_TOKEN}|#{RE_QUOTED_STRING})#{RE_LWS}?)*}n - # :startdoc: - def content_type_parse # :nodoc: vs = @metas['content-type'] # The last (?:;#{RE_LWS}?)? matches extra ";" which violates RFC2045. -- cgit v1.2.3