rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* Rack::Lint and Set-Cookie
@ 2010-01-29 12:57 agilesoftware
  2010-02-01  5:09 ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: agilesoftware @ 2010-01-29 12:57 UTC (permalink / raw)
  To: Rack Development

in Utils.set_cookie_header!(header, key, value)

  case header["Set-Cookie"]
      when Array
        header["Set-Cookie"] << cookie
      when String
        header["Set-Cookie"] = [header["Set-Cookie"], cookie]
      when nil
        header["Set-Cookie"] = cookie
      end

but in Rack::Lint:

    def check_headers(header)
      header.each { |key, value|
         .......
        assert("a header value must be a String, but the value of " +
          "'#{key}' is a #{value.class}") { value.kind_of? String }
        ## consisting of lines (for multiple header values, e.g.
multiple
        ## <tt>Set-Cookie</tt> values) seperated by "\n".
        value.split("\n").each { |item|
          ## The lines must not contain characters below 037.
          assert("invalid header value #{key}: #{item.inspect}") {
            item !~ /[\000-\037]/
          }
        }
      }
    end


So if I have any Set-Cookie header set in my Rack application, Lint
will fail.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Rack::Lint and Set-Cookie
  2010-01-29 12:57 Rack::Lint and Set-Cookie agilesoftware
@ 2010-02-01  5:09 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2010-02-01  5:09 UTC (permalink / raw)
  To: rack-devel

agilesoftware <agilesoftware@gmail.com> wrote:
> in Utils.set_cookie_header!(header, key, value)
> 
>   case header["Set-Cookie"]
>       when Array
>         header["Set-Cookie"] << cookie
>       when String
>         header["Set-Cookie"] = [header["Set-Cookie"], cookie]
>       when nil
>         header["Set-Cookie"] = cookie
>       end
> 
> but in Rack::Lint:
> 
>     def check_headers(header)
>       header.each { |key, value|
>          .......
>         assert("a header value must be a String, but the value of " +
>           "'#{key}' is a #{value.class}") { value.kind_of? String }
>         ## consisting of lines (for multiple header values, e.g.
> multiple
>         ## <tt>Set-Cookie</tt> values) seperated by "\n".
>         value.split("\n").each { |item|
>           ## The lines must not contain characters below 037.
>           assert("invalid header value #{key}: #{item.inspect}") {
>             item !~ /[\000-\037]/
>           }
>         }
>       }
>     end
> 
> 
> So if I have any Set-Cookie header set in my Rack application, Lint
> will fail.

Hi,

If your header is a Rack::Utils::HeaderHash object, then header.each
should be yielding strings in Rack 1.1.0:

------------- rack-1.1.0/lib/rack/utils.rb -------------------
    class HeaderHash < Hash
      # snipped
      def each
        super do |k, v|
          yield(k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v)
        end
      end
--------------------------------------------------------------

On the other hand, another user reported something similar on the
Unicorn mailing list, too (still unresolved):

  http://mid.gmane.org/AAD43046-6AF4-4685-933D-41F7E1DC0795@meticulo.com

I could not reproduce the issue when I tried...

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-01  5:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-29 12:57 Rack::Lint and Set-Cookie agilesoftware
2010-02-01  5:09 ` Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).