From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniele Nicolodi Newsgroups: gmane.emacs.devel Subject: Re: Bug in url-retrieve-synchronously from url.el on redirect Date: Fri, 10 Jul 2020 18:55:28 -0600 Message-ID: References: <08fad79e-9b6b-6ff4-66fd-c32fdf5b7189@grinta.net> <8d25cbf6-5cc8-25d5-89bc-5a7a74d477c4@grinta.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------25B5F8F58A853152D8F1CABF" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14615"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: emacs-devel@gnu.org, wmperry@gnu.org, monnier@iro.umontreal.ca Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 11 02:56:12 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ju3oK-0003hH-2T for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Jul 2020 02:56:12 +0200 Original-Received: from localhost ([::1]:35694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ju3oJ-0004dA-3i for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Jul 2020 20:56:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ju3nk-00047f-LG for emacs-devel@gnu.org; Fri, 10 Jul 2020 20:55:36 -0400 Original-Received: from grinta.net ([109.74.203.128]:56916) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ju3ni-0002Kc-9O; Fri, 10 Jul 2020 20:55:36 -0400 Original-Received: from 688dnmac.campus.nist.gov (unknown [132.163.252.162]) (Authenticated sender: daniele) by grinta.net (Postfix) with ESMTPSA id EC51FE0EFA; Sat, 11 Jul 2020 00:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=grinta.net; s=2020; t=1594428931; bh=JcnWG/7EdoAdqvaXMp3CkNOW7V6B2vNr6IV1Omsd770=; h=Subject:To:References:From:Date:In-Reply-To:From; b=Fxa672GLjA4Ch1OyVkBLyT8ChKSkDSDUwFYy9zFO0o2wKwQtBGVY8fjkhOmu9MTvl yJAi509+rfHMKatdN8yLhsT8RZ7JU9PyTyWoquqfWZFH767uOH+db5NcfP6ibdKplG s1OzxX8BKjiZHadlVLA4o10WNtlNLnRCEz6f6fq9U6wkWM3Pla/BsdSQAlnoxhel9n VVxHxmRv/FNm7bj3w2GGu7rMy3jmWxVrhGIcsbWblyBSKFKA1IPCdEG7JXn9KmOEkn wmHD5u+Z5DFXFP8rqWRx/byKB0urMghb08VagQ9y87uVfHwKYbsPimBQktd+pciVbJ 7rlyU1Imhyj2A== In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=109.74.203.128; envelope-from=daniele@grinta.net; helo=grinta.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/10 20:55:31 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:252849 Archived-At: This is a multi-part message in MIME format. --------------25B5F8F58A853152D8F1CABF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 10-07-2020 14:32, Daniele Nicolodi wrote: > On 10/07/2020 14:25, Yuri Khan wrote: >> On Sat, 11 Jul 2020 at 02:43, Daniele Nicolodi wrote: >> >>> As far as I understand the RFCs (and being wrong before, I may be wrong >>> again) do not allow for < > quoting either. Why does url-http.el strip >>> them? Why does it break the URI at the first space if spaces are not >>> allowed? >> >> I cannot answer that, maybe someone who is knowledgeable about >> uri-http.el chimes in. >> >> RFC 7231 allows clients to attempt to DTRT with invalid Location URIs >> in any way they deem appropriate; you could argue for a different >> recovery heuristic. Me, I’d rather have things break loudly on each >> violation, so that it does not go unnoticed for too long. Postel’s >> Razor is how we got HTML in its current shape. > > I tend to agree with you, but, in this specific case, being compatible > with other HTTP implementations is a worthwhile goal. > > Unfortunately, re-defining url-http-parse-headers is the only > work-around I found to make Emacs do the less bad thing when dealing > with this malformed URIs. Bill, you seem to be the author of this code, although Stefan is the one that introduced it to the Emacs accordingly to git blame. Do any of you know why the redirect Location is handled like that? I would like to suggest the two attached patches. The first fixes actual issues I encountered, the second simply adjusts a comment. Thank you. Cheers, Dan --------------25B5F8F58A853152D8F1CABF Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0001-url-http-Fix-handling-of-redirect-locations.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-url-http-Fix-handling-of-redirect-locations.patch" RnJvbSAwNTJhOTkzNDM4MGZkZDc1MTdiNWJmMzhhY2EzN2FhZjk1MWE2NDRlIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBEYW5pZWxlIE5pY29sb2RpIDxkYW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XNwL3VybC91cmwtaHR0cC5lbApA QCAtNzAyLDEyICs3MDIsNiBAQCBzaG91bGQgYmUgc2hvd24gdG8gdGhlIHVzZXIuIgogCSAg ICA7OyBUcmVhdCBldmVyeXRoaW5nIGxpa2UgJzMwMCcKIAkgICAgbmlsKSkKIAkgKHdoZW4g cmVkaXJlY3QtdXJpCi0JICAgOzsgQ2xlYW4gb2ZmIGFueSB3aGl0ZXNwYWNlIGFuZC9vciA8 Li4uPiBjcnVmdC4KLQkgICAoaWYgKHN0cmluZy1tYXRjaCAiXFwoW14gXHRdK1xcKVsgXHRd IiByZWRpcmVjdC11cmkpCi0JICAgICAgIChzZXRxIHJlZGlyZWN0LXVyaSAobWF0Y2gtc3Ry aW5nIDEgcmVkaXJlY3QtdXJpKSkpCi0JICAgKGlmIChzdHJpbmctbWF0Y2ggIl48XFwoLipc XCk+JCIgcmVkaXJlY3QtdXJpKQotCSAgICAgICAoc2V0cSByZWRpcmVjdC11cmkgKG1hdGNo LXN0cmluZyAxIHJlZGlyZWN0LXVyaSkpKQotCiAJICAgOzsgU29tZSBzdHVwaWQgc2l0ZXMg KGxpa2Ugc291cmNlZm9yZ2UpIHNlbmQgYQogCSAgIDs7IG5vbi1mdWxseS1xdWFsaWZpZWQg VVJMIChpZTogLyksIHdoaWNoIHJveWFsbHkgY29uZnVzZXMKIAkgICA7OyB0aGUgVVJMIGxp YnJhcnkuCi0tIAoyLjI0LjMgKEFwcGxlIEdpdC0xMjgpCgo= --------------25B5F8F58A853152D8F1CABF Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0002-url-http-Do-not-suggest-a-broken-HTTP-server-impleme.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename*0="0002-url-http-Do-not-suggest-a-broken-HTTP-server-impleme.pa"; filename*1="tch" RnJvbSA4ZGEzMzI2ZjY0YWFlYjQ3ZjQzMDZhNGJhY2MzMDY3ZDRiYzM4MTQxIE1vbiBTZXAg MTcgMDA6MDA6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