Changed HttpRequest.path to be a Unicode object. It has already been

URL-decoded by the time we see it anyway, so keeping it as a UTF-8 bytestring
was causing unnecessary problems.

Also added handling for non-ASCII URL fragments in feed creation (the portion
that was outside the control of the Feed class was messed up).



git-svn-id: http://code.djangoproject.com/svn/django/trunk@5629 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-07-07 17:15:54 +00:00
parent 347704d2df
commit fad7247715
3 changed files with 6 additions and 4 deletions

View File

@ -2,14 +2,14 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.template import Context, loader, Template, TemplateDoesNotExist from django.template import Context, loader, Template, TemplateDoesNotExist
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.utils import feedgenerator from django.utils import feedgenerator
from django.utils.encoding import smart_unicode from django.utils.encoding import smart_unicode, iri_to_uri
from django.conf import settings from django.conf import settings
def add_domain(domain, url): def add_domain(domain, url):
if not url.startswith('http://'): if not url.startswith('http://'):
# 'url' must already be ASCII and URL-quoted, so no need for encoding # 'url' must already be ASCII and URL-quoted, so no need for encoding
# conversions here. # conversions here.
url = u'http://%s%s' % (domain, url) url = iri_to_uri(u'http://%s%s' % (domain, url))
return url return url
class FeedDoesNotExist(ObjectDoesNotExist): class FeedDoesNotExist(ObjectDoesNotExist):

View File

@ -2,6 +2,7 @@ from django.core.handlers.base import BaseHandler
from django.core import signals from django.core import signals
from django.dispatch import dispatcher from django.dispatch import dispatcher
from django.utils import datastructures from django.utils import datastructures
from django.utils.encoding import force_unicode
from django import http from django import http
from pprint import pformat from pprint import pformat
import os import os
@ -13,7 +14,7 @@ import os
class ModPythonRequest(http.HttpRequest): class ModPythonRequest(http.HttpRequest):
def __init__(self, req): def __init__(self, req):
self._req = req self._req = req
self.path = req.uri self.path = force_unicode(req.uri)
def __repr__(self): def __repr__(self):
# Since this is called as part of error handling, we need to be very # Since this is called as part of error handling, we need to be very

View File

@ -2,6 +2,7 @@ from django.core.handlers.base import BaseHandler
from django.core import signals from django.core import signals
from django.dispatch import dispatcher from django.dispatch import dispatcher
from django.utils import datastructures from django.utils import datastructures
from django.utils.encoding import force_unicode
from django import http from django import http
from pprint import pformat from pprint import pformat
from shutil import copyfileobj from shutil import copyfileobj
@ -73,7 +74,7 @@ def safe_copyfileobj(fsrc, fdst, length=16*1024, size=0):
class WSGIRequest(http.HttpRequest): class WSGIRequest(http.HttpRequest):
def __init__(self, environ): def __init__(self, environ):
self.environ = environ self.environ = environ
self.path = environ['PATH_INFO'] self.path = force_unicode(environ['PATH_INFO'])
self.META = environ self.META = environ
self.method = environ['REQUEST_METHOD'].upper() self.method = environ['REQUEST_METHOD'].upper()