summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorjaepark <jaepark@google.com>2016-09-08 13:34:18 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-08 13:34:19 -0700
commit3451c0900cbbc06d82a07bca3670ac87ec36f52e (patch)
tree4ab7a98b7919f8a82ca6e1b09a0e4d9cc4703da8 /core
parentc29fc707b24b9528e41a242cfa298275708ffc76 (diff)
downloadpdfium-3451c0900cbbc06d82a07bca3670ac87ec36f52e.tar.xz
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
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/cpdf_annotlist.cpp6
1 files changed, 4 insertions, 2 deletions
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<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot,
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 @@ std::unique_ptr<CPDF_Annot> 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();