From c4f3d8d78a2ee626e4b0b9dab58c18c941dfa870 Mon Sep 17 00:00:00 2001 From: Masayuki Imamura Date: Sun, 20 Apr 2014 20:32:22 +0900 Subject: [PATCH] fix regular expression error --- lib/signet.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/signet.rb b/lib/signet.rb index 3f14a15..5b572a2 100644 --- a/lib/signet.rb +++ b/lib/signet.rb @@ -18,16 +18,16 @@ module Signet #:nodoc: def self.parse_auth_param_list(auth_param_string) # Production rules from: # http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-12 - token = /[-!#$\%&'*+.^_`|~0-9a-zA-Z]+/ + token = /[-!#$\%&'*+.^_`|~0-9a-zA-Z]+/n d_qdtext = /[\s\x21\x23-\x5B\x5D-\x7E\x80-\xFF]/n d_quoted_pair = /\\[\s\x21-\x7E\x80-\xFF]/n - d_qs = /"(?:#{d_qdtext}|#{d_quoted_pair})*"/ + d_qs = /"(?:#{d_qdtext}|#{d_quoted_pair})*"/n # Production rules that allow for more liberal parsing, i.e. single quotes s_qdtext = /[\s\x21-\x26\x28-\x5B\x5D-\x7E\x80-\xFF]/n s_quoted_pair = /\\[\s\x21-\x7E\x80-\xFF]/n - s_qs = /'(?:#{s_qdtext}|#{s_quoted_pair})*'/ + s_qs = /'(?:#{s_qdtext}|#{s_quoted_pair})*'/n # Combine the above production rules to find valid auth-param pairs. - auth_param = /((?:#{token})\s*=\s*(?:#{d_qs}|#{s_qs}|#{token}))/ + auth_param = /((?:#{token})\s*=\s*(?:#{d_qs}|#{s_qs}|#{token}))/n auth_param_pairs = [] position = 0 last_match = nil @@ -38,7 +38,7 @@ def self.parse_auth_param_list(auth_param_string) # This would be way easier in Ruby 1.9, but we want backwards # compatibility. while (match = remainder.match(auth_param)) - if match.pre_match && match.pre_match !~ /^[\s,]*$/ + if match.pre_match && match.pre_match !~ /^[\s,]*$/n raise ParseError, "Unexpected auth param format: '#{auth_param_string}'." end @@ -46,18 +46,18 @@ def self.parse_auth_param_list(auth_param_string) remainder = match.post_match last_match = match end - if last_match.post_match && last_match.post_match !~ /^[\s,]*$/ + if last_match.post_match && last_match.post_match !~ /^[\s,]*$/n raise ParseError, "Unexpected auth param format: '#{auth_param_string}'." end # Now parse the auth-param pair strings & turn them into key-value pairs. return (auth_param_pairs.inject([]) do |accu, pair| name, value = pair.split('=', 2) - if value =~ /^".*"$/ + if value =~ /^".*"$/n value = value.gsub(/^"(.*)"$/, '\1').gsub(/\\(.)/, '\1') - elsif value =~ /^'.*'$/ + elsif value =~ /^'.*'$/n value = value.gsub(/^'(.*)'$/, '\1').gsub(/\\(.)/, '\1') - elsif value =~ /[\(\)<>@,;:\\\"\/\[\]?={}]/ + elsif value =~ /[\(\)<>@,;:\\\"\/\[\]?={}]/n # Certain special characters are not allowed raise ParseError, ( "Unexpected characters in auth param " +