diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-01-28 13:59:57 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-01-28 13:59:57 +0000 |
| commit | 4a1be98aee7aba994645d943af0a31aaab6ee11e (patch) | |
| tree | a8cfc7b848050bb55028cafca6567e6862bd9821 /django | |
| parent | 2777cd37a8ceb04e3d4b28de674f9600ff0e0b4a (diff) | |
[1.1.X] Fixed #8758 -- Corrected handling of tag creation in feeds when the URL contains a port number.
Partial backport of r12338 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12340 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/utils/feedgenerator.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index c9445f932f..7e5a4a0ae3 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -19,8 +19,8 @@ For definitions of the different versions of RSS, see: http://diveintomark.org/archives/2004/02/04/incompatible-rss """ -import re import datetime +import urlparse from django.utils.xmlutils import SimplerXMLGenerator from django.utils.encoding import force_unicode, iri_to_uri @@ -46,12 +46,16 @@ def rfc3339_date(date): return date.strftime('%Y-%m-%dT%H:%M:%SZ') 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) + """ + Creates a TagURI. + + See http://diveintomark.org/archives/2004/05/28/howto-atom-id + """ + url_split = urlparse.urlparse(url) + d = '' if date is not None: - tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, 1) - tag = re.sub('#', '/', tag) - return u'tag:' + tag + d = ',%s' % date.strftime('%Y-%m-%d') + return u'tag:%s%s:%s/%s' % (url_split.hostname, d, url_split.path, url_split.fragment) class SyndicationFeed(object): "Base class for all syndication feeds. Subclasses should provide write()" |
