summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-09-23 20:43:35 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-09-23 20:43:35 +0000
commit219cd4db7e62878b3bd2cb537c73cb8acf04bf47 (patch)
tree696c5258b56a004223a0843171791adba5fa96b5 /src/couchdb/couch_httpd.erl
parenta954fd36827fbeffdb505c06cadb960d947e754b (diff)
reject attempts to upload invalid UTF-8 JSON. Closes COUCHDB-345
This patch requires JSON to be encoded using UTF-8. In the future we will accept other encodings. Thanks Joan Touzet and James Dumay for the bug reports and Curt Arnold for patches and discussion. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@818249 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd.erl')
-rw-r--r--src/couchdb/couch_httpd.erl3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index bdceab33..ac9ec723 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -181,6 +181,9 @@ handle_request(MochiReq, DefaultFun,
catch
throw:{http_head_abort, Resp0} ->
{ok, Resp0};
+ throw:{invalid_json, S} ->
+ ?LOG_ERROR("attempted upload of invalid JSON ~s", [S]),
+ send_error(HttpReq, {bad_request, "invalid UTF-8 JSON"});
exit:normal ->
exit(normal);
throw:Error ->