Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#7494 closed (fixed)

build_absolute_url method of the HttpRequest class fails with urls with : in their path

Reported by: tom@… Owned by: RobotAdam
Component: HTTP handling Version: master
Severity: Keywords: aug22sprint
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

When build_absolute_url is called for a location that should contain a ":" character in it's path it fails to add the "http://www.example.com" part.

This is because off line 76 of django/http/init.py where "if not ':' in location:" is used to check if the location is already absolute.

According to http://www.faqs.org/rfcs/rfc1738.html it is perfectly valid to have a ":" in the path part of a HTTP url.

Attachments (2)

fix_absolute_url_check_in_get_absolute_url.diff (890 bytes) - added by tom@… 7 years ago.
Patch that fixes the problem
fix_absolute_url_check_with_tests.diff (1.5 KB) - added by RobotAdam 7 years ago.
Updated patch including tests

Download all attachments as: .zip

Change History (10)

Changed 7 years ago by tom@…

Patch that fixes the problem

comment:1 Changed 7 years ago by anonymous

  • Component changed from Uncategorized to HTTP handling
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by ericholscher

  • milestone set to 1.0
  • Needs tests set
  • Owner changed from nobody to ericholscher
  • Patch needs improvement set
  • Status changed from new to assigned

The https:// shouldn't be hard coded in. This looks like it is a bug though.

comment:3 Changed 7 years ago by ericholscher

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 7 years ago by ericholscher

  • Owner ericholscher deleted
  • Status changed from assigned to new

Changed 7 years ago by RobotAdam

Updated patch including tests

comment:5 Changed 7 years ago by RobotAdam

  • Keywords aug22sprint added
  • Owner set to RobotAdam
  • Status changed from new to assigned

The "https?" in the regexp is correct with the question mark. I've updated the patch with tests that confirm it.

comment:6 Changed 7 years ago by RobotAdam

  • Needs tests unset

comment:7 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [8490]) Fixed #7494 -- Fixed build_absolute_url() for some types of (uncommon) URLs.
Patch from tom@… and RobotAdam.

comment:8 Changed 4 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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