Project

General

Profile

Actions

Bug #19153

closed

Since 2.7.7 CGI::Cookie raises ArgumentError when cookie domains is prefixed with a dot

Added by cpinto (Celso Pinto) over 1 year ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [arm64-darwin22]
[ruby-core:111022]

Description

The rspec tests of our Rails app started failing with an ArgumentError after upgrading to 2.7.7. On inspection, the issue seems to be caused by CGI::Cookie.domain=:

def domain=(str)
      if str and ((str = str.b).bytesize > 255 or !DOMAIN_VALUE_RE.match?(str))
        raise ArgumentError, "invalid domain: #{str.dump}"
      end
      @domain = str
    end

Setting a breakpoint:

0> str
=> ".example.com"

0> DOMAIN_VALUE_RE
=> /\A(?(?!-)[-A-Za-z0-9]+(?<!-))(?:.\g)*\z/

0> DOMAIN_VALUE_RE.match?(str)
=> false

0> DOMAIN_VALUE_RE.match?('example.com')
=> true

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0