pgsql: Fix IsValidJsonNumber() to notice trailing non-alphanumeric garb

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix IsValidJsonNumber() to notice trailing non-alphanumeric garb
Date: 2016-02-03 06:40:09
Message-ID: E1aQr6n-00077i-BU@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix IsValidJsonNumber() to notice trailing non-alphanumeric garbage.

Commit e09996ff8dee3f70 was one brick shy of a load: it didn't insist
that the detected JSON number be the whole of the supplied string.
This allowed inputs such as "2016-01-01" to be misdetected as valid JSON
numbers. Per bug #13906 from Dmitry Ryabov.

In passing, be more wary of zero-length input (I'm not sure this can
happen given current callers, but better safe than sorry), and do some
minor cosmetic cleanup.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/1c291624b29dae2049ff1c7008563fbca85df658

Modified Files
--------------
contrib/hstore/expected/hstore.out | 16 ++++++------
contrib/hstore/sql/hstore.sql | 4 +--
src/backend/utils/adt/json.c | 52 ++++++++++++++++++++++++--------------
3 files changed, 43 insertions(+), 29 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2016-02-03 14:10:16 pgsql: postgres_fdw: Allow fetch_size to be set per-table or per-server
Previous Message Tom Lane 2016-02-03 05:41:46 Re: pgsql: Add support for systemd service notifications