1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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.
This commit is contained in:
Andrew Dunstan
2014-06-03 16:11:31 -04:00
parent f30015b6d7
commit 0ad1a81632
7 changed files with 77 additions and 7 deletions

View File

@ -111,6 +111,14 @@ SET LOCAL TIME ZONE -8;
select to_json(timestamptz '2014-05-28 12:22:35.614298-04');
COMMIT;
-- unicode escape - backslash is not escaped
select to_json(text '\uabcd');
-- any other backslash is escaped
select to_json(text '\abcd');
--json_agg
SELECT json_agg(q)