django/django — pull request #705 by jtinfors (2013-02-07 23:35:48+00:00)
Title: make utils/http.same_origin check if ports are set before comparing

The utils/http.same_origin is used by the csrf middleware to check same origin.
But it is missing the fact that sometimes the HTTP_HOST header might have port set and when comparing the HTTP_REFERER (which most likely does not have HTTP_HOST set) that same_origin test will report a REASON_BAD_REFERER when probably it should not.

And so I think we should check if port is present before performing the same_origin check.
test and fix is provided.