Opened 9 years ago

Closed 8 years ago

#17550 closed Bug (fixed)

WSGI request to /subdir/subdir returns the index page

Reported by: Diederik van der Boor Owned by: Aymeric Augustin
Component: Core (URLs) Version: 1.4-alpha-1
Severity: Normal Keywords:
Cc: Grzegorz Szczepańczyk, Rafał Jagoda Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When hosting a Django folder in a subdirectory, using:

    WSGIScriptAlias /foo/bar  /path/to/

Then the index page is also available at /foo/bar/foo/bar (repeated script prefix, without a slash).
When stepping through the Django code, this seems to be caused by the following line in the WSGIRequest.__init__() method:

    if not path_info or path_info == script_name:

Attachments (1)

17550.diff (853 bytes) - added by Grzegorz Szczepańczyk 9 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 9 years ago by Diederik van der Boor

Amending, the result of that sets request.path_info = u'/' theirby producing an inconsistent state:

  • request.META['REQUEST_URI'] = /foo/bar/foo/bar?querystring
  • request.path = /foo/bar/
  • request.path_info = /

Where both path and path_info should have been prefixed with another /foo/bar from the request.

Last edited 9 years ago by Diederik van der Boor (previous) (diff)

comment:2 Changed 9 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

As explained in the source, this condition is a workaround for a bug in flup, reported in #8490 and fixed at r8569. I don't know if that bug was reported to flup.

flup 1.0.2 was released 2.5 years ago, if it fixes the bug, maybe we can get rid of this hack...

Changed 9 years ago by Grzegorz Szczepańczyk

Attachment: 17550.diff added

comment:3 Changed 9 years ago by Grzegorz Szczepańczyk

Cc: Grzegorz Szczepańczyk added
Has patch: set
Triage Stage: AcceptedUnreviewed

Flup 1.0.1 has wrong interpretation of path_info for /foo/bar uri - it's set to /foo/bar instead of . It's equal to script_name, but's true while uri == /foo/bar/foo/bar in other cases.
This patch should fix problem with current and old bug.
Tested on apache mod_wsgi, flup 1.0.1 and

comment:4 Changed 9 years ago by Rafał Jagoda

Cc: Rafał Jagoda added
Triage Stage: UnreviewedReady for checkin

comment:5 Changed 8 years ago by Aymeric Augustin

Triage Stage: Ready for checkinDesign decision needed

Do we really want to maintain and extend hacks in Django, just to support buggy and abandoned third party software?

flup's tracker is broken. The last release dates back to 3.5 years ago.

Unless the maintainers of flup commit to fixing their bugs within a decent timeframe (ie. 6 months), my vote is to revert r8569.

comment:6 Changed 8 years ago by Aymeric Augustin

Owner: changed from nobody to Aymeric Augustin
Status: newassigned

I'll ask Malcolm for permission to revert r8569 next time I meet him.

comment:7 Changed 8 years ago by Aymeric Augustin

Triage Stage: Design decision neededAccepted

comment:8 Changed 8 years ago by Aymeric Augustin <aymeric.augustin@…>

Resolution: fixed
Status: assignedclosed

In f5dbb566ee07bf3328015c70574b832052b4ebb7:

Fixed #17550 -- Removed a workaround for a bug in flup 1.0.1.

This reverts commit 948a833eb7fd9be0bc2d585c92a407f036ef42b2.

flup appears to be dead, and this fix breaks legitimate uses of Django.

Refs #8490.

Note: See TracTickets for help on using tickets.
Back to Top