diff options
author | Nicolas Pena <npm@chromium.org> | 2017-07-06 10:53:01 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-10 14:33:02 +0000 |
commit | 217644c0d65abfc9729c083074d505b22cd7ccf6 (patch) | |
tree | 4b8fb7bb97c4573fa85df466fc3d6e8a3a4cd896 | |
parent | 4183f201c5155717762df48e5d68330b754070f3 (diff) | |
download | pdfium-217644c0d65abfc9729c083074d505b22cd7ccf6.tar.xz |
Force unicodes into valid ranges
U+D800 to U+DFFF should not be encoded in UTF-16. However, FreeType may
have charcodes in that range, so in that case we just say that the
corresponding unicode is U+0000, NULL.
Bug: chromium:732272
Change-Id: I64e82856bab7f69545a307da1fef4df7f9df1f00
Reviewed-on: https://pdfium-review.googlesource.com/7312
Commit-Queue: Nicolás Peña <npm@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | fpdfsdk/fpdfedittext.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp index f15f9e4e6a..02bf722462 100644 --- a/fpdfsdk/fpdfedittext.cpp +++ b/fpdfsdk/fpdfedittext.cpp @@ -111,6 +111,9 @@ void AddCharcode(std::ostringstream* pBuffer, uint32_t number) { // PDF spec 1.7 Section 5.9.2: "Unicode character sequences as expressed in // UTF-16BE encoding." See https://en.wikipedia.org/wiki/UTF-16#Description void AddUnicode(std::ostringstream* pBuffer, uint32_t unicode) { + if (unicode >= 0xD800 && unicode <= 0xDFFF) + unicode = 0; + char ans[8]; *pBuffer << "<"; size_t numChars = FXSYS_ToUTF16BE(unicode, ans); |