summaryrefslogtreecommitdiff
path: root/fpdfsdk/formfiller/cba_fontmap.cpp
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-09-12 15:02:28 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-12 15:02:28 -0700
commit860a2d0299996d253272d831c9c7e533e9d3e890 (patch)
treea7ec36a857f995d67bfe9abdd7db5a170fd38080 /fpdfsdk/formfiller/cba_fontmap.cpp
parentdb319ec6a9330e75276b873f6027caddf2a15ec0 (diff)
downloadpdfium-860a2d0299996d253272d831c9c7e533e9d3e890.tar.xz
Remove GetDictBy("DR") from annot/field dictionaries
We should not use DR field from annotation/field dictionaries, since these are not supposed to have one. In PDF spec 1.7, DR is defined only for the form dictionary, in 8.6.1. In addition, note 118 in Appendix H says "In PDF 1.2, an additional entry in the field dictionary, DR, was defined but was never implemented. Beginning with PDF 1.5, this entry is obsolete and should be ignored." The changes in CBA_FontMap fix the bug below. The changes in cpvt_generateap do not affect the bug but follow the reasoning from the above paragraph. BUG=pdfium:538 Review-Url: https://codereview.chromium.org/2337673002
Diffstat (limited to 'fpdfsdk/formfiller/cba_fontmap.cpp')
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp41
1 files changed, 17 insertions, 24 deletions
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index a816e2ce7f..575f6c3145 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -219,36 +219,29 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
sDA = pObj ? pObj->GetString() : CFX_ByteString();
}
}
+ if (sDA.IsEmpty())
+ return nullptr;
+ CPDF_SimpleParser syntax(sDA.AsStringC());
+ syntax.FindTagParamFromStart("Tf", 2);
+ CFX_ByteString sFontName(syntax.GetWord());
+ sAlias = PDF_NameDecode(sFontName).Mid(1);
CPDF_Dictionary* pFontDict = nullptr;
- if (!sDA.IsEmpty()) {
- CPDF_SimpleParser syntax(sDA.AsStringC());
- syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString sFontName(syntax.GetWord());
- sAlias = PDF_NameDecode(sFontName).Mid(1);
+ if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP")) {
+ if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N")) {
+ if (CPDF_Dictionary* pNormalResDict =
+ pNormalDict->GetDictBy("Resources")) {
+ if (CPDF_Dictionary* pResFontDict = pNormalResDict->GetDictBy("Font"))
+ pFontDict = pResFontDict->GetDictBy(sAlias);
+ }
+ }
+ }
- if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR"))
+ if (bWidget && !pFontDict && pAcroFormDict) {
+ if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR")) {
if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
pFontDict = pDRFontDict->GetDictBy(sAlias);
-
- if (!pFontDict)
- if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP"))
- if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N"))
- if (CPDF_Dictionary* pNormalResDict =
- pNormalDict->GetDictBy("Resources"))
- if (CPDF_Dictionary* pResFontDict =
- pNormalResDict->GetDictBy("Font"))
- pFontDict = pResFontDict->GetDictBy(sAlias);
-
- if (bWidget) {
- if (!pFontDict) {
- if (pAcroFormDict) {
- if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR"))
- if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
- pFontDict = pDRFontDict->GetDictBy(sAlias);
- }
- }
}
}