Fix crash when users have non-ascii chars in names

Review Request #2657 — Created Oct. 14, 2011 and submitted

isak
Review Board
reviewboard
Fix crash when users have non-ascii chars in names

The HTTP headers are not allowed to contain other than US-ASCII characters,
so if users have names containing non-ascii characters their infobox would
not be shown, since django's http.HttpResponse._convert_to_ascii function
throws a UnicodeError if value.encode('us-ascii') fails.
Manually tested by creating a user "asdf" with last name "Näsman", which made /users/asdf/infobox crash, until I applied this patch after which the page showed up correctly.
Description From Last Updated

Hi guys! I've viewed the bugfix, but according to http://docs.python.org/howto/unicode.html 'replace' replaces everything with a '?' character, however 'xmlcharrefreplace' replaces ...

DH dhorvath
IS
chipx86
  1. Looks reasonable. Would you mind providing a testcase for this (reviews/tests.py) that simulates access with a user containing such characters, and verifying what the ETag should be? This will help ensure this doesn't regress.
  2. 
      
DH
  1. 
      
  2. reviewboard/reviews/views.py (Diff revision 1)
     
     
    Hi guys!
    
    I've viewed the bugfix, but according to http://docs.python.org/howto/unicode.html 'replace' replaces everything with a '?' character, however 'xmlcharrefreplace' replaces everything with it's XML form, which practically means, that special characters will remain the same when they are displayed on the webpage.
    
    So maybe using 'xmlcharrefreplace' would be a better solution :) Or does 'replace' keep the original names?
  3. 
      
OZ
  1. Ship It!
  2. 
      
QI
  1. Ship It!
  2. 
      
IS
Review request changed

Status: Closed (submitted)

Loading...