Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue14132

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Redirect is not working correctly in urllib2
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.6, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: ezio.melotti, facundobatista, gregory.p.smith, janik, karlcow, martin.panter, orsenthil, python-dev
Priority:normalKeywords:patch

Created on2012-02-26 15:15 byjanik, last changed2022-04-11 14:57 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
urllib2_redirect_fix.patchjanik,2012-02-26 15:15The possible bug fix
urllib2_redirect_fix.2.patchmartin.panter,2015-05-26 03:55review
Messages (7)
msg154356 -(view)Author: Ján Janech (janik)Date: 2012-02-26 15:15
When only the query string is sent by the server as the redirect url, urllib2 redirects to incorrect address.Error is occuring on the pagehttp://kniznica.uniza.sk/opac. Server sends only the query string part of the uri in the Location header (ie. ?fs=04D07295D4434730A51C95A9F1727373&fn=main). Path is then incorrectly stripped from the original url, and urllib2 redirects tohttp://kniznica.uniza.sk/?fs=04D07295D4434730A51C95A9F1727373&fn=main.The error was introduced in the fix of the issue#2464. I think, the attached patch is fixing the error (it is working for me).
msg154357 -(view)Author: Ján Janech (janik)Date: 2012-02-26 15:16
I forgot to mention that the correct url in the example would behttp://kniznica.uniza.sk/opac?fs=04D07295D4434730A51C95A9F1727373&fn=main.
msg183577 -(view)Author: karl (karlcow)*Date: 2013-03-06 03:39
→  curl -sIhttp://kniznica.uniza.sk/opacHTTP/1.1 302 Moved TemporarilyDate: Wed, 06 Mar 2013 03:23:06 GMTServer: Indy/9.0.50Content-Type: text/htmlLocation: ?fs=C79F09C9F1304E7AA4FF7C211BEA2B9B&fn=main→ python3.3Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import urllib.parse>>> urllib.parse.urlparse("http://kniznica.uniza.sk/opac")ParseResult(scheme='http', netloc='kniznica.uniza.sk', path='/opac', params='', query='', fragment='')>>> urllib.parse.urlparse("?fs=C79F09C9F1304E7AA4FF7C211BEA2B9B&fn=main")ParseResult(scheme='', netloc='', path='', params='', query='fs=C79F09C9F1304E7AA4FF7C211BEA2B9B&fn=main', fragment='')Redirection is defined athttp://hg.python.org/cpython/file/5e294202f93e/Lib/urllib/request.py#l643
msg243875 -(view)Author: Martin Panter (martin.panter)*(Python committer)Date: 2015-05-23 00:58
The proposed patch looks good to me. A test case would be nice though.Also I wonder why the “malformed URL” logic needs to be in urllib.request. Surely it either belongs in urljoin(), or in the underlying http.client. That needs more thought, but either way the current patch is a definite improvement.
msg244080 -(view)Author: Martin Panter (martin.panter)*(Python committer)Date: 2015-05-26 03:55
urllib2_redirect_fix.2.patch adds a test.I was tempted to remove the whole block of code setting the path to “/”, but there is one minor disadvantage: if a redirect points to a so-called “malformed” URL without any path component, like “http://example.net” or “http://example.net?query”, geturl() would return this URL verbatim.
msg265514 -(view)Author: Martin Panter (martin.panter)*(Python committer)Date: 2016-05-14 10:38
I will try to commit this soon
msg265683 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2016-05-16 08:15
New changeset52a7f580580c by Martin Panter in branch '3.5':Issue#14132: Fix redirect handling when target is just a query stringhttps://hg.python.org/cpython/rev/52a7f580580cNew changeset789a3f87bde1 by Martin Panter in branch '2.7':Issue#14132: Fix redirect handling when target is just a query stringhttps://hg.python.org/cpython/rev/789a3f87bde1New changeset841a9a3f3cf6 by Martin Panter in branch 'default':Issue#14132, Issue#17214: Merge two redirect handling fixes from 3.5https://hg.python.org/cpython/rev/841a9a3f3cf6
History
DateUserActionArgs
2022-04-11 14:57:27adminsetgithub: 58340
2020-01-03 21:29:39ned.deilysetmessages: -msg359255
2020-01-03 21:29:24ned.deilysettype: performance -> behavior
components: + Library (Lib), - XML
2020-01-03 20:41:49orsenthilsetnosy: -Joony898i

title: SEO Services Development & PHP development -> Redirect is not working correctly in urllib2
2020-01-03 20:19:48Joony898isettitle: Redirect is not working correctly in urllib2 -> SEO Services Development & PHP development
nosy: +Joony898i

messages: +msg359255

components: + XML, - Library (Lib)
type: behavior -> performance
2016-05-16 09:45:40martin.pantersetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2016-05-16 08:15:10python-devsetnosy: +python-dev
messages: +msg265683
2016-05-14 10:38:39martin.pantersetstage: patch review -> commit review
messages: +msg265514
versions: - Python 3.4
2015-05-26 03:55:01martin.pantersetfiles: +urllib2_redirect_fix.2.patch

stage: test needed -> patch review
messages: +msg244080
versions: + Python 3.6
2015-05-23 00:58:52martin.pantersetversions: + Python 3.4, Python 3.5
nosy: +martin.panter

messages: +msg243875

stage: test needed
2013-03-06 03:39:14karlcowsetnosy: +karlcow
messages: +msg183577
2012-02-26 15:18:27ezio.melottisetnosy: +facundobatista,gregory.p.smith,orsenthil,ezio.melotti
2012-02-26 15:16:37janiksetmessages: +msg154357
2012-02-26 15:15:31janikcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp