Opened 10 years ago

Last modified 10 years ago

#24321 closed Bug

`utils.http.same_origin` doesn't comply with RFC6454 — at Version 1

Reported by: Lukas Klein Owned by: nobody
Component: Utilities Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Lukas Klein)

According to RFC6454 (http://tools.ietf.org/html/rfc6454#section-3.2.1) this should both be true:

>>> from django.utils.http import same_origin
>>> same_origin('http://google.com', 'http://google.com')
True
>>> same_origin('http://google.com', 'http://google.com:80')
False

Quote:

All of the following resources have the same origin:

http://example.com/
http://example.com:80/
http://example.com/path/file

Each of the URIs has the same scheme, host, and port components.

Django's same_origin uses the standard urllib, which will return an empty port if none is explicitly specified.

My suggestion (see GitHub pull request: https://github.com/django/django/pull/4108) is to extend same_origin to use a protocol-to-port-mapping if no port is explicitly declared.

Change History (1)

comment:1 by Lukas Klein, 10 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top