pgsql: Do not escape a unicode sequence when escaping JSON text. - Mailing list pgsql-committers

From Andrew Dunstan
Subject pgsql: Do not escape a unicode sequence when escaping JSON text.
Date
Msg-id E1WrvAJ-0001W3-Jz@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Do not escape a unicode sequence when escaping JSON text.

Previously, any backslash in text being escaped for JSON was doubled so
that the result was still valid JSON. However, this led to some perverse
results in the case of Unicode sequences, These are now detected and the
initial backslash is no longer escaped. All other backslashes are
still escaped. No validity check is performed, all that is looked for is
\uXXXX where X is a hexidecimal digit.

This is a change from the 9.2 and 9.3 behaviour as noted in the Release
notes.

Per complaint from Teodor Sigaev.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0ad1a816320a2b539a51628e2a0b1e83ff096b1d

Modified Files
--------------
doc/src/sgml/release-9.4.sgml         |   15 +++++++++++++++
src/backend/utils/adt/json.c          |   21 ++++++++++++++++++++-
src/test/regress/expected/json.out    |   14 ++++++++++++++
src/test/regress/expected/json_1.out  |   14 ++++++++++++++
src/test/regress/expected/jsonb.out   |    6 +++---
src/test/regress/expected/jsonb_1.out |    6 +++---
src/test/regress/sql/json.sql         |    8 ++++++++
7 files changed, 77 insertions(+), 7 deletions(-)


pgsql-committers by date:

Previous
From: Andrew Dunstan
Date:
Subject: pgsql: Output timestamps in ISO 8601 format when rendering JSON.
Next
From: Andrew Dunstan
Date:
Subject: pgsql: Use EncodeDateTime instead of to_char to render JSON timestamps.