Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-09-22 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Accepted   | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  1  |  
+---
Comment (by semenov):

 IanLewis, you are mistaken. Unicode is a ''character set'', not an
 ''encoding''. That doesn't make sense to ''encode urls in ... Unicode''.
 URLs can be encoded in UTF8, CP1251 or any other encoding which are all
 mappings from a character set (Unicode) to particular byte strings.
 (Getting into details, URLs are actually encoded '''twice''' -- first from
 Unicode to byte strings, then from byte strings to lower-ASCII strings
 using the %XX notation).

 This ticket title mentions Unicode URLs and I consider that to be
 perfectly fine.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-09-21 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Accepted   | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  1  |  
+---
Comment (by IanLewis):

 Unicode in the bug title should read non-ascii. Remember, it's possible to
 encode urls in other encodings besides Unicode.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-06 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  1  |  
+---
Comment (by BlindHunter):

 The problem is in value.encode('us-ascii') - this codec can't encode my
 url as it contains a file named in russian. A serious bug :(
 In order to skip encoding check you can override in HttpResponseRedirect
 method  _convert_to_ascii:

 {{{
 def _convert_to_ascii(self, *values):
 """Converts all values to ascii strings."""
 for value in values:
 if isinstance(value, unicode):
 try:
 value = value.encode('us-ascii')
 except:
 pass
 else:
 value = str(value)
 if '\n' in value or '\r' in value:
 raise BadHeaderError("Header values can't contain newlines
 (got %r)" % (value))
 yield value

 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-06 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  1  |  
+---
Changes (by semenov):

  * has_patch:  0 => 1

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-06 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  1  |  
+---
Changes (by semenov):

  * needs_better_patch:  0 => 1

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-06 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by semenov):

 Perhaps (a) can be improved to apply fix_location_header logic, and then
 we'll don't need the fix_location_header middleware at all.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-06 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by semenov):

 Update on this ticket:

 1) The proposed workaround does not work anymore in Django 1.1. Use the
 following:

 {{{
 #!python
 def myview(request):
 print request.path # '/info/Интеграция/'
 return HttpResponseRedirect('?edit=1') # crashes
 return HttpResponseRedirect(request.path + '?edit=1') # still crashes
 return HttpResponseRedirect(request.build_absolute_uri('?edit=1')) #
 doesn't crash, but violates DRY principle
 }}}

 2) I disregard my words about "moving the call to iri_to_uri blah-blah-
 blah..", they don't make sense, as that's what [10539] was actually about.

 3) Still, I consider [10539] to be the cause of the problem. I can see two
 ways to fix the issue:

 a) a special case in HttpResponse.__setitem__ to handle 'Location' header
 properly (attached)[[br]]
 b) practically revert [10539], but instead of calling iri_to_uri in each
 and every case (as it was before [10539]), call fix_location_header
 instead. That is worse, as fix_location_header will be called twice then.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-06 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by BlindHunter):

 It seems to me that you well-formed message is disregarded for more than
 two weeks ;)
 All the peculiarities and moments are important for a real developer. I'll
 try to use wikiformatting in my future posts.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-06 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by semenov):

 BlindHunter, would you mind using the wiki formatting - and, what is more
 important, the "Preview" button? Your text is hardly readable and if I
 were a Django developer, I would just disregard it.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-05 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by BlindHunter):

 Ok, 11638 was closed.
 It's not necessarily relative path. Imagine what would be if you redirect
 to a file in russian utf-8:

 # -*- coding: utf-8 -*-
 path =
 '/var/www/filez/site_media/upload/alecs/отпуск-2009-ОРС.pdf'.decode('utf8')
 return HttpResponseRedirect(path)

 UnicodeEncodeError at
 /file/365d13241be1e1a3ac00523a5deddec4f577e01f813ded539bcbac32

 ('ascii',
 
u'/var/www/filez/site_media/upload/alecs/\u043e\u0442\u043f\u0443\u0441\u043a-2009-\u041e\u0420\u0421.pdf',
 39, 45, 'ordinal not in range(128)')

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-08-05 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
+---
  Reporter:  semenov| Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by kmtracey):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 #11638 closed as a dup.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #11522: Crash on redirect to a relative URL if request.path is unicode

2009-07-22 Thread Django
#11522: Crash on redirect to a relative URL if request.path is unicode
---+
 Reporter:  semenov|   Owner:  nobody
   Status:  new|   Milestone:
Component:  Uncategorized  | Version:  SVN   
 Keywords: |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 If a view for a URL which contains unicode characters returns a
 HttpResponseRedirect to a non-absolute URL, django crashes.

 Example,

 {{{
 #!python
 def myview(request):
 print request.path # '/info/Интеграция_CMS/'
 return HttpResponseRedirect('?edit=1')
 }}}

 gives the following error message:

 {{{
 URI:
 
'/info/\xd0\x98\xd0\xbd\xd1\x82\xd0\xb5\xd0\xb3\xd1\x80\xd0\xb0\xd1\x86\xd0\xb8\xd1\x8f_CMS/'

 ...

 Traceback (most recent call last):

   ...

   File "/usr/lib/python2.5/site-packages/django/http/utils.py", line 20,
 in fix_location_header
 response['Location'] =
 request.build_absolute_uri(response['Location'])

   File "/usr/lib/python2.5/site-packages/django/http/__init__.py", line
 314, in __setitem__
 header, value = self._convert_to_ascii(header, value)

   File "/usr/lib/python2.5/site-packages/django/http/__init__.py", line
 306, in _convert_to_ascii
 yield value.encode('us-ascii')

 UnicodeEncodeError: 'ascii' codec can't encode characters in position
 28-37: ordinal not in range(128), HTTP response headers must be in US-
 ASCII format
 }}}

 The cause of the problem is that #10267 was incorrectly fixed by [10539],
 leaving many other cases open. The call to iri_to_uri should be moved from
 HttpResponseRedirect?.init (and other places where it had been copy-
 pasted) deeper to django.utils.http.fix_location_header.

 Apart of my problem, it was reported in #10267 that
 django.views.generic.simple.redirect_to and django.contrib.redirects also
 suffer from the similar encoding issue, which would also be resolved once
 fix_location_header is fixed appropriately.

 For those Google strangers who are interested in a workaround, you can do
 as follows:
 {{{
 #!python
 def myview(request):
 print request.path # '/info/Интеграция_CMS/'
 return HttpResponseRedirect('?edit=1') # crashes
 return HttpResponseRedirect(request.path + '?edit=1') # doesn't crash
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---