summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirkjan Ochtman <djc@apache.org>2013-08-03 18:22:30 +0200
committerDirkjan Ochtman <djc@apache.org>2013-08-03 18:22:30 +0200
commitc843cef7e90036bb91c3e066d32143d46e80e322 (patch)
treead6221cd4c26395e6fdfbd7adef4c448696b83d8
parent05401801cc3e795cf41f889c00e90e7742320eba (diff)
parente0a9f38cfec4a2bf5ca508c0a393c83826795b50 (diff)
downloadcouchdb-c843cef7e90036bb91c3e066d32143d46e80e322.tar.gz
Merge remote-tracking branch 'adamlofts/1493-fix-zerobyte-json-parsing'
-rw-r--r--share/www/script/test/utf8.js1
-rw-r--r--src/ejson/yajl/yajl_encode.c7
2 files changed, 8 insertions, 0 deletions
diff --git a/share/www/script/test/utf8.js b/share/www/script/test/utf8.js
index b77845d3b..04f6313ab 100644
--- a/share/www/script/test/utf8.js
+++ b/share/www/script/test/utf8.js
@@ -23,6 +23,7 @@ couchTests.utf8 = function(debug) {
texts[2] = "3. Math: ∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i),"
texts[3] = "4. Geek: STARGΛ̊TE SG-1"
texts[4] = "5. Braille: ⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌"
+ texts[5] = "6. null \u0000 byte"
// check that we can save a reload with full fidelity
for (var i=0; i<texts.length; i++) {
diff --git a/src/ejson/yajl/yajl_encode.c b/src/ejson/yajl/yajl_encode.c
index ad5b1c591..d5b2b8f0d 100644
--- a/src/ejson/yajl/yajl_encode.c
+++ b/src/ejson/yajl/yajl_encode.c
@@ -173,6 +173,13 @@ void yajl_string_decode(yajl_buf buf, const unsigned char * str,
Utf32toUtf8(codepoint, utf8Buf);
unescaped = utf8Buf;
+
+ if (codepoint == 0) {
+ yajl_buf_append(buf, unescaped, 1);
+ beg = ++end;
+ continue;
+ }
+
break;
}
default: