JSON parser discards value of string token

From: Antonin Houska <ah(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: JSON parser discards value of string token
Date: 2019-09-12 15:51:50
Message-ID: 34021.1568303510@antos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Although the following problem does not seem to be exposed in the core, I
think it's still a problem to fix. (I've hit it when implementing a custom
parser for extension configuration file.)

If makeJsonLexContextCstringLen() is passed need_escapes=false,
JsonLexContext.strval is not initialized, and in turn, functions of
JsonSemAction which should receive the string token value
(e.g. object_field_start) receive NULL.

Attached is a patch that fixes the problem. If this approach is acceptable,
then it'd probably be worth to also rename the JsonLexContext.strval field to
something that recalls the "de-escaping", e.g. "noesc"?

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

Attachment Content-Type Size
do_not_discard_json_string_token.patch text/x-diff 1.1 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2019-09-12 15:54:06 Re: [PATCH] Incremental sort (was: PoC: Partial sort)
Previous Message Tom Lane 2019-09-12 15:51:10 Leakproofness of texteq()/textne()