Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Handle UTF-8 #22

Merged
merged 1 commit into from
Aug 24, 2016
Merged

Handle UTF-8 #22

merged 1 commit into from
Aug 24, 2016

Conversation

laanwj
Copy link
Contributor

@laanwj laanwj commented Apr 18, 2016

This adds full UTF-8 support both on input and output.

Input: read and validate full UTF-8, both Basic Multilingual Plane and extended characters.
Collate surrogate pairs as specified in RFC4627.
This ensures that UTF-8 strings that reach the application are always valid, and that invalid UTF-8 fails parsing.

Output: Assume UTF-8 strings provided for output are valid.
The escaping was broken, fix this by not encoding UTF-8 characters with \u.
Writing them to the output stream as-is is the right thing to do.
See https://www.ietf.org/rfc/rfc4627.txt:

"JSON text SHALL be encoded in Unicode.  The default encoding is UTF-8."

Also add tests for the new functionality.
Fixes #16.
Sister PR in the bitcoin core repository, with examples: Add full UTF-8 support to RPC #7892

@maflcko
Copy link
Contributor

maflcko commented Apr 18, 2016

You didn't adjust src/univalue/Makefile.am?

@laanwj
Copy link
Contributor Author

laanwj commented Apr 18, 2016

Ah yes, thanks for noticing, this needs the build system changes

Edit: done

This adds full UTF-8 support both on input and output.

Input: read and validate full UTF-8, both Basic Multilingual Plane
and extended characters.
Collate surrogate pairs as specified in RFC4627.
This ensures that UTF-8 strings that reach the application are
always valid, and that invalid UTF-8 fails parsing.

Output: Assume UTF-8 strings provided for output are valid.
The escaping was broken, fix this by not encoding UTF-8 characters with \u.
Writing them to the output stream as-is is the right thing to do.
See https://www.ietf.org/rfc/rfc4627.txt:

    "JSON text SHALL be encoded in Unicode.  The default encoding is UTF-8."

Also add tests for the new functionality.
Fixes #16.
@maflcko
Copy link
Contributor

maflcko commented May 27, 2016

Concept ACK

laanwj added a commit to bitcoin-core/univalue-subtree that referenced this pull request Jun 10, 2016
@luke-jr
Copy link

luke-jr commented Aug 16, 2016

This seems fairly well-tested in Core. Would be nice to have it in an official release of the lib too...

@maflcko
Copy link
Contributor

maflcko commented Aug 24, 2016

@jgarzik Anything holding this back?

@jgarzik jgarzik merged commit 09a2693 into jgarzik:master Aug 24, 2016
martinus pushed a commit to martinus/univalue that referenced this pull request Feb 13, 2021
54c4015 Clamp JSON object depth to PHP limit (Jeff Garzik)

Pull request description:

  Cherry-picks jgarzik#64 to fix CVE-2019-18936.

  Based on fe2227d

ACKs for top commit:
  MarcoFalke:
    ACK 54c4015 📣

Tree-SHA512: d21458bcfdd37abd84daad46cead0635098d3b1ecd86720c48e724f5e3fcbea39692e1b1fbb2e0d9401a5121df44f280dc6eba8e3ace474c8f4cdb81004a6189
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UTF-8 not handled while writing
4 participants