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 6BB9A9B4D for ; Wed, 28 Mar 2012 12:00:23 +0000 (UTC) Received: (qmail 58469 invoked by uid 500); 28 Mar 2012 12:00:21 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 58425 invoked by uid 500); 28 Mar 2012 12:00:21 -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 58413 invoked by uid 99); 28 Mar 2012 12:00:21 -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 12:00:21 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=NORMAL_HTTP_TO_IP,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [212.246.151.130] (HELO MAIL.insta.fi) (212.246.151.130) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Mar 2012 12:00:16 +0000 Received: from mail.insta.fi ([10.20.10.3]) by MAIL.insta.fi ([10.20.10.3]) with mapi; Wed, 28 Mar 2012 14:59:52 +0300 From: Aalto Jukka To: "user@couchdb.apache.org" Date: Wed, 28 Mar 2012 14:59:51 +0300 Subject: RE: Cannot add JSON-document containing quotes Thread-Topic: Cannot add JSON-document containing quotes Thread-Index: Ac0M031eilizZ7kcQ8uYA9uR/4wbHQABVCWw Message-ID: <503EB32C9885B2468531E6D637BE411226A7B3E4E3@MAIL.insta.fi> References: <503EB32C9885B2468531E6D637BE411226A7B3E478@MAIL.insta.fi> In-Reply-To: Accept-Language: en-US, fi-FI Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, fi-FI Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org I tried your example but it gave the same error. It seems to add the document, but when I'm fetching it the error is logged.= =20 I cannot add and fetch document containing quotes. I have also tried to add= and get it using futon and ektorp. -----Original Message----- From: Paul Davis [mailto:paul.joseph.davis@gmail.com]=20 Sent: 28. maaliskuuta 2012 14:10 To: user@couchdb.apache.org Subject: Re: Cannot add JSON-document containing quotes 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