Code

Opened 5 years ago

Closed 4 years ago

#10787 closed (duplicate)

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

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

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

Attachments (0)

Change History (3)

comment:1 Changed 5 years ago by rpwagner

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 5 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by seanbrant

  • Resolution set to duplicate
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.