general: always encode json as utf-8 (#36515)
This commit is contained in:
parent
e9f5112fbe
commit
fd0b882578
12
wcs/api.py
12
wcs/api.py
|
@ -238,9 +238,7 @@ class ApiFormsDirectory(Directory):
|
|||
if FormDef.count() == 0:
|
||||
# early return, this avoids running a query against a missing SQL view.
|
||||
get_response().set_content_type('application/json')
|
||||
return json.dumps({'data': []},
|
||||
cls=misc.JSONEncoder,
|
||||
encoding=get_publisher().site_charset)
|
||||
return json.dumps({'data': []}, cls=misc.JSONEncoder)
|
||||
|
||||
from wcs import sql
|
||||
|
||||
|
@ -290,9 +288,7 @@ class ApiFormsDirectory(Directory):
|
|||
for x in formdatas]
|
||||
|
||||
get_response().set_content_type('application/json')
|
||||
return json.dumps({'data': output},
|
||||
cls=misc.JSONEncoder,
|
||||
encoding=get_publisher().site_charset)
|
||||
return json.dumps({'data': output}, cls=misc.JSONEncoder)
|
||||
|
||||
|
||||
def geojson(self):
|
||||
|
@ -711,9 +707,7 @@ class ApiUserDirectory(Directory):
|
|||
formdata_dict['readable'] = getattr(form, 'readable', True)
|
||||
result.append(formdata_dict)
|
||||
|
||||
return json.dumps({'err': 0, 'data': result},
|
||||
cls=misc.JSONEncoder,
|
||||
encoding=get_publisher().site_charset)
|
||||
return json.dumps({'err': 0, 'data': result}, cls=misc.JSONEncoder)
|
||||
|
||||
|
||||
class ApiUsersDirectory(Directory):
|
||||
|
|
|
@ -1762,8 +1762,7 @@ class FormPage(Directory):
|
|||
'receipt_time': filled.receipt_time,
|
||||
'last_update_time': filled.last_update_time} for filled in items]
|
||||
return json.dumps(output,
|
||||
cls=misc.JSONEncoder,
|
||||
encoding=get_publisher().site_charset)
|
||||
cls=misc.JSONEncoder)
|
||||
|
||||
def geojson(self):
|
||||
if not self.formdef.geolocations:
|
||||
|
|
|
@ -1082,9 +1082,7 @@ class FormData(StorableObject):
|
|||
|
||||
def export_to_json(self, include_files=True, anonymise=False):
|
||||
data = self.get_json_export_dict(include_files=include_files, anonymise=anonymise)
|
||||
return json.dumps(data,
|
||||
cls=misc.JSONEncoder,
|
||||
encoding=get_publisher().site_charset)
|
||||
return json.dumps(data, cls=misc.JSONEncoder)
|
||||
|
||||
def mark_as_being_visited(self):
|
||||
object_key = 'formdata-%s-%s' % (self.formdef.url_name, self.id)
|
||||
|
|
|
@ -108,8 +108,7 @@ def call_webservice(url, qs_data=None, request_signature_key=None,
|
|||
if method in ('PATCH', 'PUT', 'POST'):
|
||||
if payload:
|
||||
headers['Content-type'] = 'application/json'
|
||||
payload = json.dumps(payload, cls=JSONEncoder,
|
||||
encoding=get_publisher().site_charset)
|
||||
payload = json.dumps(payload, cls=JSONEncoder)
|
||||
response, status, data, auth_header = misc._http_request(
|
||||
url, method=method, body=payload, headers=headers)
|
||||
elif method == 'DELETE':
|
||||
|
|
Loading…
Reference in New Issue