Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id A67F2C955BE for ; Mon, 4 Jun 2012 21:48:23 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sbhwc-0007QR-A5 for pgsql-bugs@postgresql.org; Tue, 05 Jun 2012 00:48:23 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q550m9g4021414; Mon, 4 Jun 2012 20:48:09 -0400 (EDT) To: Shigeru Hanada cc: pgsql-bugs@postgresql.org Subject: Re: control character check in JSON type seems broken In-reply-to: References: Comments: In-reply-to Shigeru Hanada message dated "Mon, 04 Jun 2012 19:41:47 +0900" Date: Mon, 04 Jun 2012 20:48:09 -0400 Message-ID: <21413.1338857289@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/31 X-Sequence-Number: 33258 Shigeru Hanada writes: > json_lex_string() misjudges that the token "キー" contains naked > (not-escaped) control character, because its first byte is 0xe3 and it's > -29 for signed char interpreting, and it's less than 32. We need to > cast to unsigned char (or use unsigned variable) here. Yeah, that's wrong. > In addition, error message above seems corrupted in my environment. > Here we check not-escaped control character, so printing it with %c > formatting might break log files. How about using decimal or hex dump > in such cases? And so is that. IMO the error reporting in this module could stand to be reviewed altogether for compliance with our message guidelines. (For starters, why is it using errdetail_internal?) I refrained from editorializing on-the-fly, but I'm not too pleased with what I saw. Patch applied, thanks! regards, tom lane