From b291397989dfe7a8a4f16cfbbe764cc6e566a19d Mon Sep 17 00:00:00 2001 From: stve Date: Wed, 13 Apr 2016 11:21:23 -0400 Subject: [PATCH] store parsed cookie attributes as symbols --- lib/secure_headers/headers/cookie.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/secure_headers/headers/cookie.rb b/lib/secure_headers/headers/cookie.rb index ef690966..2ccf73b7 100644 --- a/lib/secure_headers/headers/cookie.rb +++ b/lib/secure_headers/headers/cookie.rb @@ -79,9 +79,9 @@ def initialize(cookie, config) @raw_cookie = cookie @config = config @attributes = { - "secure" => nil, - "httponly" => nil, - "samesite" => nil, + httponly: nil, + samesite: nil, + secure: nil, } parse(cookie) @@ -114,7 +114,7 @@ def parsed_cookie end def already_flagged?(attribute) - @attributes[attribute.to_s] + @attributes[attribute] end def flag_cookie?(attribute) @@ -178,8 +178,9 @@ def parse(cookie) name, values = pairs.split('=',2) name = CGI.unescape(name) - if @attributes.has_key?(name.downcase) - @attributes[name.downcase] = values || true + attribute = name.downcase.to_sym + if @attributes.has_key?(attribute) + @attributes[attribute] = values || true end end end