Revision 4e571185 snf-cyclades-app/synnefo/plankton/views.py

b/snf-cyclades-app/synnefo/plankton/views.py
39 39

  
40 40
from django.conf import settings
41 41
from django.http import HttpResponse
42
from django.utils.encoding import smart_unicode, smart_str
42
from django.utils.encoding import (smart_unicode, smart_str,
43
                                   DjangoUnicodeDecodeError)
43 44

  
44 45
from snf_django.lib import api
45 46
from snf_django.lib.api import faults
......
128 129

  
129 130
    params = {}
130 131
    properties = {}
131
    for key, val in request.META.items():
132
        if isinstance(val, basestring):
133
            val = decode_header(val)
134
        if is_img_property(key):
135
            key = decode_header(key[META_PROPERTY_PREFIX_LEN:])
136
            properties[normalize(key)] = val
137
        elif is_img_param(key):
138
            key = decode_header(key[META_PREFIX_LEN:])
139
            params[normalize(key)] = val
132
    try:
133
        for key, val in request.META.items():
134
            if isinstance(val, basestring):
135
                val = decode_header(val)
136
            if is_img_property(key):
137
                key = decode_header(key[META_PROPERTY_PREFIX_LEN:])
138
                properties[normalize(key)] = val
139
            elif is_img_param(key):
140
                key = decode_header(key[META_PREFIX_LEN:])
141
                params[normalize(key)] = val
142
    except DjangoUnicodeDecodeError:
143
        raise faults.BadRequest("Could not decode request as UTF-8 string")
140 144

  
141 145
    if properties:
142 146
        params['properties'] = properties

Also available in: Unified diff