lib/rack/utils.rb in rack-2.2.8 vs lib/rack/utils.rb in rack-2.2.8.1

- old
+ new

@@ -140,12 +140,12 @@ "#{prefix}=#{escape(value)}" end end def q_values(q_value_header) - q_value_header.to_s.split(/\s*,\s*/).map do |part| - value, parameters = part.split(/\s*;\s*/, 2) + q_value_header.to_s.split(',').map do |part| + value, parameters = part.split(';', 2).map(&:strip) quality = 1.0 if parameters && (md = /\Aq=([\d.]+)/.match(parameters)) quality = md[1].to_f end [value, quality] @@ -378,9 +378,12 @@ r1 = size - 1 if r1 >= size end end ranges << (r0..r1) if r0 <= r1 end + + return [] if ranges.map(&:size).sum > size + ranges end # Constant time string comparison. #