Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C2E8D9317 for ; Wed, 28 Mar 2012 11:11:09 +0000 (UTC) Received: (qmail 30636 invoked by uid 500); 28 Mar 2012 11:11:08 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 30564 invoked by uid 500); 28 Mar 2012 11:11:08 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 30540 invoked by uid 99); 28 Mar 2012 11:11:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Mar 2012 11:11:07 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.212.52 as permitted sender) Received: from [209.85.212.52] (HELO mail-vb0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Mar 2012 11:10:49 +0000 Received: by vbzb23 with SMTP id b23so833561vbz.11 for ; Wed, 28 Mar 2012 04:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=Zp5X2VXu56gR1y9UIE7ssB5UC761NcHgeOXt7RK+Rjs=; b=QaLVJ9BHorAhb4TAgomukfFSkgHSfg9VozpQJBS3ijeESC9qoc3jkM5gWNimEW8yHb MOZNTs1RWk+2gFd6O4agk+epEnydG8Kuz62am6i4KWHVUffkgIE/C9cDsOrbJgZ/C13Y +zyJRySVSZv/HQyJjb9ODn0ddPN1xpPnZ0dNEZho8zosF1r321toqJgq0RE/b1NupAao drYAYF97WIJSXbxlBTgnHrf0akmYrAEFIKX17IXTU2ulXKe6KBULtJl5U0nEQ32SxYQf uNUEQww/jsqCPkotrA50jtG3P5SI0CGBeLfYR8ZTY16vHJ5bkD7dLIx7dlETcOXCFOD+ xalg== Received: by 10.52.28.200 with SMTP id d8mr11489739vdh.38.1332933028996; Wed, 28 Mar 2012 04:10:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.144.67 with HTTP; Wed, 28 Mar 2012 04:09:48 -0700 (PDT) In-Reply-To: <503EB32C9885B2468531E6D637BE411226A7B3E478@MAIL.insta.fi> References: <503EB32C9885B2468531E6D637BE411226A7B3E478@MAIL.insta.fi> From: Paul Davis Date: Wed, 28 Mar 2012 06:09:48 -0500 Message-ID: Subject: Re: Cannot add JSON-document containing quotes To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org You're running into shell escape issues: $ curl -X PUT http://127.0.0.1:5984/bing {"ok":true} $ curl -X PUT -H "Content-Type: application/json" http://127.0.0. 1:5984/bing/bob -d '{"key":"va\"lue"}' {"ok":true,"id":"bob","rev":"1-9424043dd7e8f320dc86b53ad024f58e"} $ curl http://127.0.0.1:5984/bing/bob {"_id":"bob","_rev":"1-9424043dd7e8f320dc86b53ad024f58e","key":"va\"lue"} On Wed, Mar 28, 2012 at 5:42 AM, Aalto Jukka wrote: > Hi, > > I cannot add JSON-document containing quotes. Below is an example where I= use Curl to add JSON-documents. > When I add {"key" : "va\"lue"} JSON document, it seems that operation suc= ceeds but there is an error in the log. > > ------------- > Versions: > -------------- > Couchdb version 1.1.0 > SUSE Linux Enterprise Server 11 SP1 =A0(x86_64) > > -------------------------------- > Commandline example > -------------------------------- > # Create database > user@server:/> curl -X PUT http://127.0.0.1:5984/test/ > {"ok":true} > > # Add JSON document id=3D1 without quote > user@server:/> curl -X PUT http://127.0.0.1:5984/test/1/ -H "Content-Type= : application/json" -d '{"key" : "value"}' > {"ok":true,"id":"1","rev":"1-59414e77c768bc202142ac82c2f129de"} > > # Get JSON document id=3D1 > user@server:/> curl -X GET http://127.0.0.1:5984/test/1/ > {"_id":"1","_rev":"1-59414e77c768bc202142ac82c2f129de","key":"value"} > > # Add JSON document id=3D2 with quote -> server error > user@server:/> curl -X PUT http://127.0.0.1:5984/test/2/ -H "Content-Type= : application/json" -d '{"key" : "va\"lue"}' > {"ok":true,"id":"2","rev":"1-9424043dd7e8f320dc86b53ad024f58e"} > > # Try to get JSON document id=3D2 > user@server:/> curl -X GET http://127.0.0.1:5984/test/2/ > {"error":"unknown_error","reason":"undef"} > > -------------------------------------------------------------------------= - > couchdb.log > -------------------------------------------------------------------------= - > [Wed, 28 Mar 2012 09:40:27 GMT] [info] [<0.14316.1189>] 127.0.0.1 - - 'PU= T' /test/ 201 > [Wed, 28 Mar 2012 09:40:38 GMT] [info] [<0.14426.1189>] 127.0.0.1 - - 'PU= T' /test/1/ 201 > [Wed, 28 Mar 2012 09:40:51 GMT] [info] [<0.14542.1189>] 127.0.0.1 - - 'GE= T' /test/1/ 200 > [Wed, 28 Mar 2012 09:41:13 GMT] [info] [<0.14749.1189>] 127.0.0.1 - - 'PU= T' /test/2/ 201 > [Wed, 28 Mar 2012 09:41:24 GMT] [error] [<0.14851.1189>] Uncaught error i= n HTTP request: {error,undef} > [Wed, 28 Mar 2012 09:41:24 GMT] [info] [<0.14851.1189>] Stacktrace: [{xme= rl_ucs,from_utf8,[<<"va\"lue">>]}, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {= mochijson2,json_encode_string,2}, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {= mochijson2, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0'-json_encode_proplist/2-fun-0-',3}, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {= lists,foldl,3}, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {= mochijson2,json_encode_proplist,2}, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {= couch_httpd,send_json,4}, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {= couch_httpd_db,do_db_req,2}, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {= couch_httpd,handle_request_int,5}] > [Wed, 28 Mar 2012 09:41:24 GMT] [info] [<0.14851.1189>] 127.0.0.1 - - 'GE= T' /test/2/ 500 > > - Jukka