You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2009/09/23 22:51:30 UTC

svn commit: r818252 - in /couchdb/branches/0.10.x: ./ THANKS etc/default/couchdb share/www/script/test/view_errors.js src/couchdb/couch_httpd.erl src/mochiweb/mochijson2.erl

Author: kocolosk
Date: Wed Sep 23 20:51:29 2009
New Revision: 818252

URL: http://svn.apache.org/viewvc?rev=818252&view=rev
Log:
merged r818249 (reject invalid UTF-8)

Modified:
    couchdb/branches/0.10.x/   (props changed)
    couchdb/branches/0.10.x/THANKS
    couchdb/branches/0.10.x/etc/default/couchdb   (props changed)
    couchdb/branches/0.10.x/share/www/script/test/view_errors.js
    couchdb/branches/0.10.x/src/couchdb/couch_httpd.erl
    couchdb/branches/0.10.x/src/mochiweb/mochijson2.erl

Propchange: couchdb/branches/0.10.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 23 20:51:29 2009
@@ -3,4 +3,4 @@
 /couchdb/branches/form:729440-730015
 /couchdb/branches/list-iterator:782292-784593
 /couchdb/branches/tail_header:775760-778477
-/couchdb/trunk:806983,807208-807478,807771,808574,808632,808716,808876,809134,809977,810015,810028,810350,810358,810435,811910,813803,815921,817278,817398,817400,817403,817749,817793
+/couchdb/trunk:806983,807208-807478,807771,808574,808632,808716,808876,809134,809977,810015,810028,810350,810358,810435,811910,813803,815921,817278,817398,817400,817403,817749,817793,818249

Modified: couchdb/branches/0.10.x/THANKS
URL: http://svn.apache.org/viewvc/couchdb/branches/0.10.x/THANKS?rev=818252&r1=818251&r2=818252&view=diff
==============================================================================
--- couchdb/branches/0.10.x/THANKS (original)
+++ couchdb/branches/0.10.x/THANKS Wed Sep 23 20:51:29 2009
@@ -37,5 +37,6 @@
  * Sebastian Cohnen <se...@gmx.net>
  * Sven Helmberger <sv...@gmx.de>
  * Dan Walters <da...@danwalters.net>
+ * Curt Arnold <ca...@apache.org>
 
 For a list of authors see the `AUTHORS` file.

Propchange: couchdb/branches/0.10.x/etc/default/couchdb
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 23 20:51:29 2009
@@ -3,5 +3,5 @@
 /couchdb/branches/form/etc/default/couchdb:729440-730015
 /couchdb/branches/list-iterator/etc/default/couchdb:782292-784593
 /couchdb/branches/tail_header/etc/default/couchdb:775760-778477
-/couchdb/trunk/etc/default/couchdb:806983,807208-807478,807771,808574,808632,808716,808876,809134,809977,810015,810028,810350,810358,810435,811910,813803,815921,817277-817278,817398,817400,817403,817749,817793
+/couchdb/trunk/etc/default/couchdb:806983,807208-807478,807771,808574,808632,808716,808876,809134,809977,810015,810028,810350,810358,810435,811910,813803,815921,817277-817278,817398,817400,817403,817749,817793,818249
 /incubator/couchdb/trunk/etc/default/couchdb:642419-694440

Modified: couchdb/branches/0.10.x/share/www/script/test/view_errors.js
URL: http://svn.apache.org/viewvc/couchdb/branches/0.10.x/share/www/script/test/view_errors.js?rev=818252&r1=818251&r2=818252&view=diff
==============================================================================
--- couchdb/branches/0.10.x/share/www/script/test/view_errors.js (original)
+++ couchdb/branches/0.10.x/share/www/script/test/view_errors.js Wed Sep 23 20:51:29 2009
@@ -55,7 +55,7 @@
           map : "function(doc){emit(doc.integer)}"
         })
       });
-      T(JSON.parse(xhr.responseText).error == "invalid_json");
+      T(JSON.parse(xhr.responseText).error == "bad_request");
 
       // views should ignore Content-Type, like the rest of CouchDB
       var xhr = CouchDB.request("POST", "/test_suite_db/_temp_view", {

Modified: couchdb/branches/0.10.x/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.10.x/src/couchdb/couch_httpd.erl?rev=818252&r1=818251&r2=818252&view=diff
==============================================================================
--- couchdb/branches/0.10.x/src/couchdb/couch_httpd.erl (original)
+++ couchdb/branches/0.10.x/src/couchdb/couch_httpd.erl Wed Sep 23 20:51:29 2009
@@ -181,6 +181,9 @@
     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"});
         throw:Error ->
             ?LOG_DEBUG("Minor error in HTTP request: ~p",[Error]),
             ?LOG_DEBUG("Stacktrace: ~p",[erlang:get_stacktrace()]),

Modified: couchdb/branches/0.10.x/src/mochiweb/mochijson2.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.10.x/src/mochiweb/mochijson2.erl?rev=818252&r1=818251&r2=818252&view=diff
==============================================================================
--- couchdb/branches/0.10.x/src/mochiweb/mochijson2.erl (original)
+++ couchdb/branches/0.10.x/src/mochiweb/mochijson2.erl Wed Sep 23 20:51:29 2009
@@ -345,10 +345,24 @@
     case B of
         <<_:O/binary, ?Q, _/binary>> ->
             O;
-        <<_:O/binary, C, _/binary>> when C =/= $\\ ->
+        <<_:O/binary, $\\, _/binary>> ->
+            {escape, O};
+        <<_:O/binary, C1, _/binary>> when C1 < 128 ->
             tokenize_string_fast(B, 1 + O);
+        <<_:O/binary, C1, C2, _/binary>> when C1 >= 194, C1 =< 223,
+                C2 >= 128, C2 =< 191 ->
+            tokenize_string_fast(B, 2 + O);
+        <<_:O/binary, C1, C2, C3, _/binary>> when C1 >= 224, C1 =< 239,
+                C2 >= 128, C2 =< 191,
+                C3 >= 128, C3 =< 191 ->
+            tokenize_string_fast(B, 3 + O);
+        <<_:O/binary, C1, C2, C3, C4, _/binary>> when C1 >= 240, C1 =< 244,
+                C2 >= 128, C2 =< 191,
+                C3 >= 128, C3 =< 191,
+                C4 >= 128, C4 =< 191 ->
+            tokenize_string_fast(B, 4 + O);
         _ ->
-            {escape, O}
+            throw(invalid_utf8)
     end.
 
 tokenize_string(B, S=#decoder{offset=O}, Acc) ->