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
diff --git a/DEPS b/DEPS
index a76674f..f87e9d6 100644
--- a/DEPS
+++ b/DEPS
@@ -14,7 +14,7 @@
'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 6319781..31c8542 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -24,7 +24,9 @@
if (!pParentDict)
return std::unique_ptr<CPDF_Annot>();
- 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<CPDF_Annot>();
@@ -32,7 +34,7 @@
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();