Opened 15 years ago

Closed 14 years ago

#10787 closed (duplicate)

debug.py Templates: Request URLs Should Include django.root

Reported by: Rick Wagner Owned by: nobody
Component: Generic views Version: dev
Severity: Keywords: debug
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

In a few place in [browser:django/trunk/django/views/debug.py] a string is built to show the request, like so:

      <th>Request URL:</th>
      <td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request.path_info|escape }}</td>

However, request.path_info is only relative to root URL of which ever settings module is being used. To correct this, the script name (e.g., django.root for Apache and mod_python), should be added.

      <th>Request URL:</th>
      <td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request.META.SCRIPT_NAME }}{{ request.path_info|escape }}</td>

One way to do this would be to modify request.path_info, but I don't think that would be correct. In particular, when listing a 404, the URLs shown should probably only be those be checked for matches, which are "below" the root URL. But, anywhere that lists the protocol, host, and path, should be corrected to match what's in the browser (or queried by a script, etc.).

From what I can see, the following lines should be updated:

  • [browser:django/trunk/django/views/debug.py#L402 402]
  • [browser:django/trunk/django/views/debug.py#L532 532]
  • [browser:django/trunk/django/views/debug.py#L744 744]

I'm hesitating on provding a patch, since I'm not sure if request.META['SCRIPT_NAME'] is always set, and where the trailing slashes are.

--Rick

Change History (3)

comment:1 by Rick Wagner, 15 years ago

Correction to my bad use of Trac linking. Here are the line numbers, with working links to the revision I was looking at:

  • [source:/django/trunk/django/views/debug.py@10271#L402 402]
  • [source:/django/trunk/django/views/debug.py@10271#L532 532]
  • [source:/django/trunk/django/views/debug.py@10271#L744 744]

--Rick

comment:2 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Sean Brant, 14 years ago

Resolution: duplicate
Status: newclosed

This was a dupe of #9577 and fixed by r10535.

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