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

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 1f2b195ebf1c1646b20111f1c339fbaebb04da56
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2016-02-03T06:39:08Z
Releases: 9.3.11
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.

Files

PathChange+/−
contrib/hstore/expected/hstore.out modified +4 −4
contrib/hstore/sql/hstore.sql modified +1 −1
src/backend/utils/adt/json.c modified +33 −19