Skip to content

Conversation

serhiy-storchaka
Copy link
Member

Fixes #2109.

@ewdurbin
Copy link
Member

ewdurbin commented Aug 9, 2022

Confirmed the old legacy cgi-bin was doing same thing:

From Apache config:

    ScriptAlias /sf /data/cgi-bin/sf

And the script:

#!/usr/bin/python
# This file is in RCS
import os, httplib, sys, cgitb, time

def num():
    try:
        return int(os.environ['PATH_INFO'][1:])
    except (KeyError, ValueError, TypeError):
        try:
            import cgi
            return int(cgi.FieldStorage().getvalue("id"))
        except (ValueError, TypeError):
            return None

def bad_request(msg):
    print "Content-type: text/html"
    print ""
    print "<html><title>Invalid report</title>"
    print "<body>"+msg+"</body></html>"
    raise SystemExit

report = num()
if not report:
    bad_request("You did not provide a report number")

location = "http://bugs.python.org/issue%s" % report
print "Location: "+location+"\n"

@ewdurbin ewdurbin merged commit 6bd101d into python:main Aug 9, 2022
@serhiy-storchaka serhiy-storchaka deleted the redirect-sf-bugs branch August 9, 2022 18:55
@serhiy-storchaka
Copy link
Member Author

Thank you. I was not sure about the existing location block, it handled paths with /sf not followed by a slash, and query parameters (e.g. /sfoo, /sf?bar=baz, /sfoo?bar=baz). I did not have any idea what use cases it supported. But seems it was just too general, the path should always start with /sf/ and no query parameters are used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Links like http://python.org/sf/1541697 no longer work
2 participants