From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.140.128.1 with SMTP id a1cs53507rvd; Tue, 9 Mar 2010 06:29:57 -0800 (PST) Received-SPF: pass (google.com: domain of 3XluWSwgJCpsMOJH5TFJBH5DG.7JHM57F-89Q9GBJJBG9BMJPKN.7JH@groups.bounces.google.com designates 10.229.11.25 as permitted sender) client-ip=10.229.11.25; Authentication-Results: mr.google.com; spf=pass (google.com: domain of 3XluWSwgJCpsMOJH5TFJBH5DG.7JHM57F-89Q9GBJJBG9BMJPKN.7JH@groups.bounces.google.com designates 10.229.11.25 as permitted sender) smtp.mail=3XluWSwgJCpsMOJH5TFJBH5DG.7JHM57F-89Q9GBJJBG9BMJPKN.7JH@groups.bounces.google.com; dkim=pass header.i=3XluWSwgJCpsMOJH5TFJBH5DG.7JHM57F-89Q9GBJJBG9BMJPKN.7JH@groups.bounces.google.com Received: from mr.google.com ([10.229.11.25]) by 10.229.11.25 with SMTP id r25mr2238189qcr.16.1268144991886 (num_hops = 1); Tue, 09 Mar 2010 06:29:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received-spf:received:mime-version:sender:received :in-reply-to:references:date:message-id:subject:from:to :x-original-authentication-results:x-original-sender:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :x-thread-url:x-message-url:list-subscribe:list-unsubscribe :content-type:content-transfer-encoding; bh=zJ3sxb/LV9UkgNRTB0tNYcxLdF+jBnBGWhCPhFOfoIA=; b=hoOJRt0hMHGkVxqC7cFoMrjpKzyVTCfIWcBy3AR2yrQQr/+SD7iz1EfMCTlndbBkd4 pemJiKFsXimOht08jyJAC+cuzpWYUndQgF0L+CRmWQmKb87pmhn7TjM/3szNe/EabYzh TAfGR9tEw1DSW+QbNVs3rXciz/s9SG1jMYGls= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:sender:in-reply-to:references :date:message-id:subject:from:to:x-original-authentication-results :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:x-thread-url:x-message-url :list-subscribe:list-unsubscribe:content-type :content-transfer-encoding; b=Xhj5YmOu0IQIWzkUwv5kGQORpLgY3gPsjbWMUOTMxvAoW5z50yyty7uEd3/vr2OfYG 3IlAcsLiOAsS+7B4+dJgwMBD/w/KD3l3CtKQ6L/BzBWHupfBKR0J7Q2rM45Rj5+rt8A0 Nvq+v7uRSIYVdtnpP7NmFhm39v88Zf+M0McV4= Received: by 10.229.11.25 with SMTP id r25mr269596qcr.16.1268144990642; Tue, 09 Mar 2010 06:29:50 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.229.100.199 with SMTP id z7ls428519qcn.0.p; Tue, 09 Mar 2010 06:29:47 -0800 (PST) Received: by 10.229.231.132 with SMTP id jq4mr666448qcb.1.1268144985545; Tue, 09 Mar 2010 06:29:45 -0800 (PST) Received: by 10.229.231.132 with SMTP id jq4mr666447qcb.1.1268144985509; Tue, 09 Mar 2010 06:29:45 -0800 (PST) Return-Path: Received: from qw-out-1920.google.com (qw-out-1920.google.com [74.125.92.147]) by gmr-mx.google.com with ESMTP id 18si1375754qyk.0.2010.03.09.06.29.44; Tue, 09 Mar 2010 06:29:44 -0800 (PST) Received-SPF: pass (google.com: domain of rtomayko@gmail.com designates 74.125.92.147 as permitted sender) client-ip=74.125.92.147; Received: by qw-out-1920.google.com with SMTP id 14so1627422qwa.8 for ; Tue, 09 Mar 2010 06:29:44 -0800 (PST) MIME-Version: 1.0 Sender: rack-devel@googlegroups.com Received: by 10.224.81.200 with SMTP id y8mr702649qak.234.1268144978665; Tue, 09 Mar 2010 06:29:38 -0800 (PST) In-Reply-To: <12d24d3c1003082020h72346a34u44d08ce591030af8@mail.gmail.com> References: <12d24d3c1003082020h72346a34u44d08ce591030af8@mail.gmail.com> Date: Tue, 9 Mar 2010 06:29:38 -0800 Message-ID: Subject: Re: content_length.rb incorrectly compares string with int, causing later exception From: Ryan Tomayko To: rack-devel@googlegroups.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of rtomayko@gmail.com designates 74.125.92.147 as permitted sender) smtp.mail=rtomayko@gmail.com; dkim=pass (test mode) header.i=@gmail.com X-Original-Sender: r@tomayko.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rack-devel/t/536421d992d795d4 X-Message-Url: http://groups.google.com/group/rack-devel/msg/346261e7a351bb44 List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Mar 8, 2010 at 8:20 PM, Larry Siden wrote: > I came across an issue that caused bytesize() to throw an exception becau= se > it was being asked to return the size of nil when an HTTP response has > status is 204 (no content). > The test on line 16 of content_length.rb should prevent it from ever > reaching this code, but neglects to convert status (an instance of String= ) > to an int before checking for inclusion in the the Set instance named by = the > constant STATUS_WITH_NO_ENTITY_BODY, which contains integers. > Please accept the following patch: > diff --git a/lib/rack/content_length.rb b/lib/rack/content_length.rb > index 1e56d43..ba72ef2 100644 > --- a/lib/rack/content_length.rb > +++ b/lib/rack/content_length.rb > @@ -13,7 +13,7 @@ module Rack > =C2=A0=C2=A0 =C2=A0 =C2=A0 status, headers, body =3D @app.call(env) > =C2=A0=C2=A0 =C2=A0 =C2=A0 headers =3D HeaderHash.new(headers) > > - =C2=A0 =C2=A0 =C2=A0if !STATUS_WITH_NO_ENTITY_BODY.include?(status) && > + =C2=A0 =C2=A0 =C2=A0if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i= ) && > =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0!headers['Content-Length'] && > =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0!headers['Transfer-Encoding'] && > =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(body.respond_to?(:to_ary) || bod= y.respond_to?(:to_str)) > I hope someone will contact me to let me know whether this has been accep= ted > and what release it will appear in. =C2=A0Thank you and G-d bless. > Larry Siden, 734-926-9614, http://umich.edu/~lsiden Applied. Thanks, Ryan