pgsql: Do not escape a unicode sequence when escaping JSON text.

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Do not escape a unicode sequence when escaping JSON text.
Date: 2014-06-03 20:18:35
Message-ID: E1WrvAJ-0001W3-Jz@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2014-06-03 22:35:54 pgsql: Use EncodeDateTime instead of to_char to render JSON timestamps.
Previous Message Andrew Dunstan 2014-06-03 17:59:14 pgsql: Output timestamps in ISO 8601 format when rendering JSON.