From 3451c0900cbbc06d82a07bca3670ac87ec36f52e Mon Sep 17 00:00:00 2001 From: jaepark Date: Thu, 8 Sep 2016 13:34:18 -0700 Subject: Check whether the annotation content is empty using CFX_WideString. CFX_ByteString cannot properly check whether the contents string is empty because the first two bytes of text strings encoded in Unicode are always ASCII 254 followed by 255. So if we get contents in CFX_ByteString, the length will always be 2. Also, roll DEPS for testing/corpus to 608bf04. Review-Url: https://codereview.chromium.org/2293403003 --- DEPS | 2 +- core/fpdfdoc/cpdf_annotlist.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DEPS b/DEPS index a76674f0dc..f87e9d6de2 100644 --- a/DEPS +++ b/DEPS @@ -14,7 +14,7 @@ vars = { 'gmock_revision': '29763965ab52f24565299976b936d1265cb6a271', 'gtest_revision': '8245545b6dc9c4703e6496d1efd19e975ad2b038', 'icu_revision': '2341038bf72869a5683a893a2b319a48ffec7f62', - 'pdfium_tests_revision': 'a7f9103f929c6ab5e2188c629d61797548e9c200', + 'pdfium_tests_revision': '6608bf041de1104595d3e9c0c18cd411d4757446', 'skia_revision': '39f7a10a04a914384944d8bf62621144ac4eeaa3', 'tools_memory_revision': '427f10475e1a8d72424c29d00bf689122b738e5d', 'trace_event_revision': '54b8455be9505c2cb0cf5c26bb86739c236471aa', diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 631978175c..31c8542daa 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -24,7 +24,9 @@ std::unique_ptr CreatePopupAnnot(CPDF_Annot* pAnnot, if (!pParentDict) return std::unique_ptr(); - CFX_ByteString sContents = pParentDict->GetStringBy("Contents"); + // TODO(jaepark): We shouldn't strip BOM for some strings and not for others. + // See pdfium:593. + CFX_WideString sContents = pParentDict->GetUnicodeTextBy("Contents"); if (sContents.IsEmpty()) return std::unique_ptr(); @@ -32,7 +34,7 @@ std::unique_ptr CreatePopupAnnot(CPDF_Annot* pAnnot, pAnnotDict->SetAtName("Type", "Annot"); pAnnotDict->SetAtName("Subtype", "Popup"); pAnnotDict->SetAtString("T", pParentDict->GetStringBy("T")); - pAnnotDict->SetAtString("Contents", sContents); + pAnnotDict->SetAtString("Contents", sContents.UTF8Encode()); CFX_FloatRect rect = pParentDict->GetRectBy("Rect"); rect.Normalize(); -- cgit v1.2.3