get_tag_uri in /django/utils/feedgenerator.py breaks with port numbers
The following function:
def get_tag_uri(url, date):
"Creates a TagURI. See http://diveintomark.org/archives/2004/05/28/howto-atom-id"
tag = re.sub('^http://', '', url)
if date is not None:
tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, 1)
tag = re.sub('#', '/', tag)
return u'tag:' + tag
}}
- http://code.djangoproject.com/browser/django/trunk/django/utils/feedgenerator.py#L48
... breaks for domain names with a port number, such as http://example.org:8080/ as this produces the following TAG value:
{{{
tag:example.org:8080,2007-09-21:/
}}}
From http://feedvalidator.org/docs/error/InvalidTAG.html and http://tools.ietf.org/html/rfc4151#section-2.1 you can see that the TAG URI should not contain the port number.
The following patch should be able to extract the domain name from the link:
{{{
- tag = re.sub('^http://', '', url)
+ tag = str(urllib.splitport(urllib.splithost(urllib.splittype(url)[1])[0])[0])
}}}
Why not use
urlparse.urlparse(url).hostname
?