Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Is CGI::Cookie::parse terribly broken?

Reply
Thread Tools

Is CGI::Cookie::parse terribly broken?

 
 
Ryan Mulligan
Guest
Posts: n/a
 
      07-23-2008
Is CGI::Cookie:arse meant to be used on the contents of the Set-Cookie
header or the Cookie header, or both?

Here is what happens when I use it on the Set-Cookie header:

require 'cgi'

# File lib/cgi.rb, line 875
# def Cookie:arse(raw_cookie)
# cookies = Hash.new([])
# return cookies unless raw_cookie

# raw_cookie.split(/[;,]\s?/).each do |pairs|
# name, values = pairs.split('=',2)
# next unless name and values
# name = CGI::unescape(name)
# values ||= ""
# values = values.split('&').collect{|v| CGI::unescape(v) }
# if cookies.has_key?(name)
# values = cookies[name].value + values
# end
# cookies[name] = Cookie::new(name, *values)
# end

# cookies
# end

asetcookie = "phpbb3_q3k1i_u=1; expires=Thu, 23-Jul-2009 17:27:04 GMT;
path=/; domain=.brawlsnapshots.com; HttpOnly, phpbb3_q3k1i_k=;
expires=Thu, 23-Jul-2009 17:27:04 GMT; path=/;
domain=.brawlsnapshots.com; HttpOnly,
phpbb3_q3k1i_sid=3c2ab8dae46098004b66dcd2ff6c3180; expires=Thu,
23-Jul-2009 17:27:04 GMT; path=/; domain=.brawlsnapshots.com; HttpOnly,
phpbb3_q3k1i_u=1000; expires=Thu, 23-Jul-2009 17:27:04 GMT; path=/;
domain=.brawlsnapshots.com; HttpOnly, phpbb3_q3k1i_k=c06c23e2a199173a;
expires=Thu, 23-Jul-2009 17:27:04 GMT; path=/;
domain=.brawlsnapshots.com; HttpOnly,
phpbb3_q3k1i_sid=85d32e487ffd5bc8fad948e327866597; expires=Thu,
23-Jul-2009 17:27:04 GMT; path=/; domain=.brawlsnapshots.com; HttpOnly"

puts "The Cookies:"
puts asetcookie

puts "Ruby says:"
puts CGI::Cookie:arse(asetcookie).inspect

OUTPUT:

ryan@rtmlap:~/rb/code/test$ ruby ~/test.rb
The Cookies:
phpbb3_q3k1i_u=1; expires=Thu, 23-Jul-2009 17:27:04 GMT; path=/;
domain=.brawlsnapshots.com; HttpOnly, phpbb3_q3k1i_k=; expires=Thu,
23-Jul-2009 17:27:04 GMT; path=/; domain=.brawlsnapshots.com; HttpOnly,
phpbb3_q3k1i_sid=3c2ab8dae46098004b66dcd2ff6c3180; expires=Thu,
23-Jul-2009 17:27:04 GMT; path=/; domain=.brawlsnapshots.com; HttpOnly,
phpbb3_q3k1i_u=1000; expires=Thu, 23-Jul-2009 17:27:04 GMT; path=/;
domain=.brawlsnapshots.com; HttpOnly, phpbb3_q3k1i_k=c06c23e2a199173a;
expires=Thu, 23-Jul-2009 17:27:04 GMT; path=/;
domain=.brawlsnapshots.com; HttpOnly,
phpbb3_q3k1i_sid=85d32e487ffd5bc8fad948e327866597; expires=Thu,
23-Jul-2009 17:27:04 GMT; path=/; domain=.brawlsnapshots.com; HttpOnly
Ruby says:
{"phpbb3_q3k1i_sid"=>["3c2ab8dae46098004b66dcd2ff6c3180",
"85d32e487ffd5bc8fad948e327866597"], "expires"=>["Thu", "Thu", "Thu",
"Thu", "Thu", "Thu"], "domain"=>[".brawlsnapshots.com",
".brawlsnapshots.com", ".brawlsnapshots.com", ".brawlsnapshots.com",
".brawlsnapshots.com", ".brawlsnapshots.com"], "phpbb3_q3k1i_u"


VERSION:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio 2008 terribly slow in Design view kcroyals1@gmail.com ASP .Net 8 05-13-2008 12:33 AM
Semi-OT: What a terribly odd Website JDS HTML 2 02-14-2005 09:38 PM
Orcon USENET server is terribly unreliable Jamie Kahn Genet NZ Computing 46 11-04-2004 03:25 PM
XLS problem? JBoss terribly slow Angus Parvis XML 2 08-31-2004 12:12 PM



Advertisments