A pattern that matches the comma in a (typically date) value.
A pattern that matches a cookie name or attribute name which may be empty, capturing trailing whitespace.
Whitespace.
# File lib/http/cookie/scanner.rb, line 18 def initialize(string, logger = nil) @logger = logger super(string) end
# File lib/http/cookie/scanner.rb, line 24 def quote(s) return s unless s.match(RE_BAD_CHAR) '"' << s.gsub(/([\"])/, "\\\\\\1") << '"' end
# File lib/http/cookie/scanner.rb, line 34 def scan_dquoted ''.tap { |s| case when skip(/"/) break when skip(/\/) s << getch when scan(/[^"\]+/) s << matched end until eos? } end
# File lib/http/cookie/scanner.rb, line 47 def scan_name scan(RE_NAME).tap { |s| s.rstrip! if s } end
# File lib/http/cookie/scanner.rb, line 71 def scan_name_value name = scan_name if skip(/\=/) value = scan_value else scan_value value = nil end [name, value] end
# File lib/http/cookie/scanner.rb, line 53 def scan_value ''.tap { |s| case when scan(/[^,;"]+/) s << matched when skip(/"/) # RFC 6265 2.2 # A cookie-value may be DQUOTE'd. s << scan_dquoted when check(/;|#{RE_COOKIE_COMMA}/) break else s << getch end until eos? s.rstrip! } end
# File lib/http/cookie/scanner.rb, line 30 def skip_wsp skip(RE_WSP) end
# File lib/http/cookie/scanner.rb, line 83 def tuple_to_time(day_of_month, month, year, time) Time.strptime( '%02d %s %04d %02d:%02d:%02d UTC' % [day_of_month, month, year, *time], '%d %b %Y %T %Z' ).tap { |date| date.day == day_of_month or return nil } end