Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3282 by (v 1.7.14) error 500/DjangoUnicodeDecodeError while doing _generate_preview_html after windows user uploads "unicode" (utf16-le) encoded file as attachment to review

What version are you running?
this could have been fixed in 1.7.22 (
but I haven't tried.

What's the URL of the page containing the problem?

What steps will reproduce the problem?
1. create a text file using notepad and save it as UTF-16LE (what windows calls "unicode") [1]
2. upload it to the review using "add a file"
3. boom error 500 "something broke contact your friendly admin".
   stack trace in _generate_preview_html

What is the expected output? What do you see instead?
correct preview file

What operating system are you using? What browser?
windows 7 / some version of IE.

Please provide any additional information below.

Maybe a testcase where a user uploads an UTF16-LE encoded file to attach to a review would
be a good addition.

2013-11-15 23:29:49,075 - ERROR - - Exception thrown for user damien at

'utf8' codec can't decode byte 0xff in position 0: invalid start byte. You passed in '\xff\xfe' (<type 'str'>)
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/django/core/handlers/", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.6/site-packages/django/views/decorators/", line 89, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/views/decorators/", line 19, in inner_func
    response = func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 465, in __call__
    result = view(request, api_format=api_format, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/djblets/util/", line 75, in _call
    f = augmented_func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/reviewboard/webapi/", line 30, in _check
    return webapi_login_required(view_func)(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 88, in _checklogin
    return view_func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 235, in _validate
    return view_func(*args, **new_kwargs)
File "/usr/lib/python2.6/site-packages/reviewboard/webapi/", line 192, in get_list
    return self._get_list_impl(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/reviewboard/webapi/", line 201, in _get_list_impl
    return super(WebAPIResource, self).get_list(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 62, in _call
    return view_func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 235, in _validate
    return view_func(*args, **new_kwargs)
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 803, in get_list
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 332, in __init__
    for obj in results]
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 801, in <lambda>
    obj, request=request, *args, **kwargs),
File "/usr/lib/python2.6/site-packages/djblets/webapi/", line 941, in serialize_object
    value = getattr(obj, field)
File "/usr/lib/python2.6/site-packages/reviewboard/attachments/", line 41, in _get_thumbnail
    return self.mimetype_handler.get_thumbnail()
File "/usr/lib/python2.6/site-packages/reviewboard/attachments/", line 251, in get_thumbnail
File "/usr/lib/python2.6/site-packages/djblets/util/", line 165, in cache_memoize
    data = lookup_callable()
File "/usr/lib/python2.6/site-packages/reviewboard/attachments/", line 241, in _generate_thumbnail
    % self._generate_preview_html(data_string))
File "/usr/lib/python2.6/site-packages/reviewboard/attachments/", line 223, in _generate_preview_html
    preview_lines[i] = escape(preview_lines[i][:self.TEXT_CROP_NUM_LENGTH])
File "/usr/lib/python2.6/site-packages/django/utils/", line 176, in wrapper
    return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/", line 36, in escape return mark_safe(force_unicode(html).replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;')) File "/usr/lib/python2.6/site-packages/django/utils/", line 93, in force_unicode
    raise DjangoUnicodeDecodeError(s, *e.args)

You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:

You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to