rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: Lawrence Pit <lawrence.pit@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: bug report and unit test for infinite loop parsing Content-Disposion header
Date: Mon, 7 May 2012 10:39:11 +1000	[thread overview]
Message-ID: <DDB223C8-A00C-4EB5-9121-D370EA9264AF@gmail.com> (raw)
In-Reply-To: <20120504233415.GA25832@dcvr.yhbt.net>


Given the value of DISPPARM must always have at least 1 character (according to RFC2183 and RFC2045) that fix seems correct to me.

In addition I would make the TOKEN regexp non-greedy (for the BROKEN_UNQUOTED case):

    TOKEN = /[^\s()<>,;:\\"\/\[\]?=]+?/

Also, why is the "@" character accepted as part of a TOKEN? It is part of the tspecials (in RFC2045), so I think it should not be accepted as a valid token character.


Cheers,
Lawrence


> I think the following should fix your issue (but I'm not sure it's
> correct):
> 
> diff --git a/lib/rack/multipart.rb b/lib/rack/multipart.rb
> index 3777106..6849248 100644
> --- a/lib/rack/multipart.rb
> +++ b/lib/rack/multipart.rb
> @@ -12,7 +12,7 @@ module Rack
>     MULTIPART = %r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|n
>     TOKEN = /[^\s()<>,;:\\"\/\[\]?=]+/
>     CONDISP = /Content-Disposition:\s*#{TOKEN}\s*/i
> -    DISPPARM = /;\s*(#{TOKEN})=("(?:\\"|[^"])*"|#{TOKEN})*/
> +    DISPPARM = /;\s*(#{TOKEN})=("(?:\\"|[^"])*"|#{TOKEN})/
>     RFC2183 = /^#{CONDISP}(#{DISPPARM})+$/i
>     BROKEN_QUOTED = /^#{CONDISP}.*;\sfilename="(.*?)"(?:\s*$|\s*;\s*#{TOKEN}=)/i
>     BROKEN_UNQUOTED = /^#{CONDISP}.*;\sfilename=(#{TOKEN})/i

  reply	other threads:[~2012-05-07  0:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-04 21:37 bug report and unit test for infinite loop parsing Content-Disposion header Paul Rogers
2012-05-04 23:34 ` Eric Wong
2012-05-07  0:39   ` Lawrence Pit [this message]
2012-05-07 15:04     ` Paul Rogers
  -- strict thread matches above, loose matches on Subject: below --
2012-05-04 21:37 Paul Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DDB223C8-A00C-4EB5-9121-D370EA9264AF@gmail.com \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).