Re: BUG #19958: jsonpath: a word directly followed by a /* comment */ is silently dropped, so strict becomes lax

From: Zejiang Zhang <rushsky518(at)gmail(dot)com>
To: Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19958: jsonpath: a word directly followed by a /* comment */ is silently dropped, so strict becomes lax
Date: 2026-12-02 08:19:54
Message-ID: CADjxURZ71V8tJBHR71u93-H0BNTmcJzyunB2-d3KywBKz=M=sA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Ishjaap,

Thanks for the patch. The fix looks correct: removing the `<xnq>\/\*` rule
allows the generic special-character rule to return the word, after which
INITIAL handles `/*` as a comment. I ran `make check`, and all 243 tests
passed.

A few suggestions:

- The `lax/* comment */$.a` test does not actually verify the fix, since
lax is the default mode and produces the same output even without the fix.
Please consider using `strict/* comment */$.a` instead, with the expected
output `strict $."a"`.
- Add a brief comment in `jsonpath_scan.l` explaining why there is
intentionally no separate `/*` rule in `xnq`, to prevent it from being
reintroduced.

Regards,
Zhang

Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com> 于2026年12月2日周三 15:32写道:

> Hi James,
>
> Thanks for the report. I can reproduce it on every supported branch
> (15 to 19) and on master. The rule goes back to the original jsonpath
> commit 72b6460336e.
>
> Your reading of the scanner is right. The <xnq>\/\* rule starts the
> comment without returning the word, and flex picks it over the
> <xnq>({special}|\") rule because "/*" is the longer match.
>
> The attached patch removes that rule. The {special} rule then treats
> "/" like any other delimiter: it returns the word, puts the "/" back,
> and "/*" is scanned as a comment from the initial state. Keeping the
> <xnq>\/\* rule and adding the missing return also works, but then the
> error for 'abc/**/1' points at "/*" instead of the end of input.
>
> It adds seven regression tests. Six fail without the fix; the lax one
> is a control. make check passes.
>
> The patch is against master and applies to 18 and 19. I also tested
> versions for 15 to 17, which use the older scanner, and make check
> passes on all five branches. I can post the backpatches if that helps.
>
> Regards,
> Ishjaap Singh
>

--
Zejiang Zhang
HighGo Software Co., Ltd.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Raja Sai pranav 2026-12-02 08:49:21 Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance
Previous Message Ishjaap Singh 2026-12-02 07:32:22 Re: BUG #19958: jsonpath: a word directly followed by a /* comment */ is silently dropped, so strict becomes lax