From a15e531fdc83c12b45930329e36591347f9b1fbb Mon Sep 17 00:00:00 2001 From: Yessiest Date: Sat, 6 Jul 2024 22:36:33 +0400 Subject: [PATCH] i have jumped too far into the bright future of the internet and found RFC 6265 to be an active standards about 50 years too early --- lib/landline/util/cookie.rb | 2 ++ lib/landline/util/parseutils.rb | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/landline/util/cookie.rb b/lib/landline/util/cookie.rb index fa50ba1..bc5a64b 100644 --- a/lib/landline/util/cookie.rb +++ b/lib/landline/util/cookie.rb @@ -115,6 +115,8 @@ module Landline data.split(";").map do |cookiestr| key, value = cookiestr.match(/([^=]+)=?(.*)/).to_a[1..].map(&:strip) + next unless key and value + cookie = Cookie.new(key, value) if hash[cookie.key] hash[cookie.key].append(cookie) diff --git a/lib/landline/util/parseutils.rb b/lib/landline/util/parseutils.rb index 17d5d73..30611b6 100644 --- a/lib/landline/util/parseutils.rb +++ b/lib/landline/util/parseutils.rb @@ -15,12 +15,16 @@ module Landline PRINTCHAR = /[\x2-\x7E]/ # Matches 1 or more CHARs excluding CTLs PRINTABLE = /#{PRINTCHAR}+/o + # !! RFC 6265 IS PROPOSED AND NOT AN IMPLEMENTED STANDARD YET !! # Matches the RFC6265 definition of a cookie-octet - COOKIE_OCTET = /[\x21-\x7E&&[^",;\\]]*/ - COOKIE_VALUE = /(?:#{QUOTED}|#{COOKIE_OCTET})/o - COOKIE_NAME = TOKEN + # COOKIE_VALUE = /(?:#{QUOTED}|#{COOKIE_OCTET})/o + # COOKIE_NAME = TOKEN # Matches the RFC6265 definition of cookie-pair. # Captures name (1) and value (2). + # !! RFC 6265 IS PROPOSED AND NOT AN IMPLEMENTED STANDARD YET !! + COOKIE_OCTET = /[\x21-\x7E&&[^",;\\]]*/ + COOKIE_NAME = /[^;,=\s]*/ + COOKIE_VALUE = /[^;,\s]*/ COOKIE_PAIR = /\A(#{COOKIE_NAME})=(#{COOKIE_VALUE})\z/o # Matches a very abstract definition of a quoted header paramter. # Captures name (1) and value (2). @@ -83,7 +87,7 @@ module Landline unless input.match? HeaderRegexp::PRINTABLE raise Landline::ParsingError, "input is not ascii printable" end - + opts.each do |key, value| check_param(key, value) newparam = if [String, Integer].include? value.class