From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/83348 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: [util-jsn] incorrect handling of escapes Date: Tue, 9 Jul 2013 11:37:43 +0200 Message-ID: <20130709093743.GA15037@phlegethon> References: <20130707225628.GA7955@phlegethon> <51DAE657.20704@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2002784972==" X-Trace: ger.gmane.org 1373362693 30074 80.91.229.3 (9 Jul 2013 09:38:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Jul 2013 09:38:13 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jul 09 11:38:12 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UwUNA-0004lF-B4 for gctc-ntg-context-518@m.gmane.org; Tue, 09 Jul 2013 11:38:12 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 555F2101EB; Tue, 9 Jul 2013 11:38:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id YV0NA+pqo8Uu; Tue, 9 Jul 2013 11:38:04 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id BB123101E4; Tue, 9 Jul 2013 11:38:04 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 62D88101E4 for ; Tue, 9 Jul 2013 11:38:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4wk4kLfXfA8A for ; Tue, 9 Jul 2013 11:38:01 +0200 (CEST) Original-Received: from filter1-ams.mf.surf.net (filter1-ams.mf.surf.net [192.87.102.69]) by balder.ntg.nl (Postfix) with ESMTP id 89565101E0 for ; Tue, 9 Jul 2013 11:37:51 +0200 (CEST) Original-Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by filter1-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r699boHs010603 for ; Tue, 9 Jul 2013 11:37:50 +0200 Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id r699boP2006967 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Jul 2013 11:37:50 +0200 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r699boZ3028400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Jul 2013 11:37:50 +0200 Original-Received: from localhost (p4FFFD2B8.dip0.t-ipconnect.de [79.255.210.184]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id r699bncY029240 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 9 Jul 2013 11:37:49 +0200 Mail-Followup-To: mailing list for ConTeXt users In-Reply-To: <51DAE657.20704@wxs.nl> X-Operating-System: Linux phlegethon 3.9.5-1-ARCH X-NSA: "None of you business!" User-Agent: Mutt/1.5.21 (2010-09-15) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=129.206.100.212; country=DE; region=01; city=Heidelberg; latitude=49.4167; longitude=8.7000; http://maps.google.com/maps?q=49.4167,8.7000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0NJW9BOC7 - 41ac7acf3c4a - 20130709 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.69 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:83348 Archived-At: --===============2002784972== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =B7=B7=B7=B7=B7=B7=B7=B7=B7 > On 7/8/2013 12:56 AM, Philipp Gesang wrote: > >Hi, > > > >the JSON parser handles backslash escapes improperly. Example: > > > > local data =3D [[ { "escapes" : "(\")(\\)(\b)(\f)(\n)(\r)(\t)", > > "invalid" : "\'\v" } ]] > > local stuff =3D utilities.json.tolua (data) > > inspect(stuff) > > > >Currently it chokes on double quotes and treats the other escapes > >like Lua. Fix suggestion attached. >=20 > local escapes =3D { > -- ["\\"] =3D "\\", -- lua will escape these > -- ["/"] =3D "/", -- no need to escape this one > ["b"] =3D "\010", > ["f"] =3D "\014", > ["n"] =3D "\n", > ["r"] =3D "\r", > ["t"] =3D "\t", > } >=20 > local escape_un =3D C(P("\\u") / "0x" * S("09","AF","af")) / > function(s) return utfchar(tonumber(s)) end > local escape_bs =3D P([[\]]) / "" * (P(1) / escapes) -- if not found > then P(1) is returned i.e. the to be escaped char >=20 > local jstring =3D dquote * Cs((escape_un + escape_bs + > (1-dquote))^0) * dquote Fine with me! Best, Philipp --mYCpIKhGyMATD0i+ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQEcBAEBCgAGBQJR29nnAAoJEI7yfcKNwM1+Ev0IAOIkIIHr9pHfw1gFkbeFkuM0 tD05vXDiezSA4IR1NN9Qgt5VazlyDt5bE7hqSXndAZHegydt/+b/bB6M+whJtCEQ 7gBoP+Lp/6yOIWIY7AVRT8cPEa8RcTkT6wW0sEv6zp4AMmofNBp62UEPVnc1QMTI CI/LpAQkeIkLxr1AoQHcworlsJfFPPek0u6O41uH593w52K66ANxE2XsT5GXHYUm B49WyNvQSlmdMifBuQOndIwFZ2JLCYr3y3l619ffSb0s5jWIopwmb8BYBVwWXDZ5 B6vyJUdQXHteAweHAc/z7UnyvW1hSPL41yfGOsbkoq2mmD9+vxUtGvcSOvaGzWs= =cpgF -----END PGP SIGNATURE----- --mYCpIKhGyMATD0i+-- --===============2002784972== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============2002784972==--