@@ -14,7 +14,7 @@ module Header
1414 # The `accept-content-type` header represents a list of content-types that the client can accept.
1515 class Accept < Array
1616 # Regular expression used to split values on commas, with optional surrounding whitespace, taking into account quoted strings.
17- SPLIT = /
17+ SEPARATOR = /
1818 (?: # Start non-capturing group
1919 "[^"\\ ]*" # Match quoted strings (no escaping of quotes within)
2020 | # OR
@@ -76,7 +76,7 @@ def split(*args)
7676
7777 def initialize ( value = nil )
7878 if value
79- super ( value . scan ( SPLIT ) . map ( &:strip ) )
79+ super ( value . scan ( SEPARATOR ) . map ( &:strip ) )
8080 else
8181 end
8282 end
@@ -87,7 +87,7 @@ def initialize(value = nil)
8787 #
8888 # @parameter value [String] the value or values to add, separated by commas.
8989 def << ( value )
90- self . concat ( value . scan ( SPLIT ) . map ( &:strip ) )
90+ self . concat ( value . scan ( SEPARATOR ) . map ( &:strip ) )
9191 end
9292
9393 # Serializes the stored values into a comma-separated string.
@@ -115,7 +115,11 @@ def parse_media_range(value)
115115 parameters = { }
116116
117117 match [ :parameters ] . scan ( PARAMETER ) do |key , value , quoted_value |
118- parameters [ key ] = quoted_value || value
118+ if quoted_value
119+ value = QuotedString . unquote ( quoted_value )
120+ end
121+
122+ parameters [ key ] = value
119123 end
120124
121125 return MediaRange . new ( type , subtype , parameters )
0 commit comments