summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorJun Fang <jun_fang@foxitsoftware.com>2015-10-26 21:07:08 +0800
committerJun Fang <jun_fang@foxitsoftware.com>2015-10-27 11:27:29 +0800
commitec44186fdbca423eddf432be8b5c38914674023a (patch)
treef8c00272fa526bb32301b3f50e618d292f154e52 /xfa
parent13dc2cff2adc00ed8fa9674e946102a79773d587 (diff)
downloadpdfium-ec44186fdbca423eddf432be8b5c38914674023a.tar.xz
Add an embedded test case
Diffstat (limited to 'xfa')
-rw-r--r--xfa/src/fxfa/src/parser/xfa_parser_imp.cpp16
-rw-r--r--xfa/src/fxfa/src/parser/xfa_parser_imp_embeddertest.cpp15
2 files changed, 30 insertions, 1 deletions
diff --git a/xfa/src/fxfa/src/parser/xfa_parser_imp.cpp b/xfa/src/fxfa/src/parser/xfa_parser_imp.cpp
index 9e85c1f539..66258980e5 100644
--- a/xfa/src/fxfa/src/parser/xfa_parser_imp.cpp
+++ b/xfa/src/fxfa/src/parser/xfa_parser_imp.cpp
@@ -433,6 +433,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
}
IFDE_XMLNode* pXMLDatasetsDOMRoot = NULL;
IFDE_XMLNode* pXMLFormDOMRoot = NULL;
+ IFDE_XMLNode* pXMLTemplateDOMRoot = NULL;
{
for (IFDE_XMLNode* pChildItem =
pXMLDocumentNode->GetNodeItem(IFDE_XMLNode::FirstChild);
@@ -473,7 +474,17 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
return NULL;
}
pXMLFormDOMRoot = pElement;
- } else {
+ } else if (ePacket == XFA_XDPPACKET_Template) {
+ if (pXMLTemplateDOMRoot) {
+ // Find a duplicate template packet
+ return NULL;
+ }
+ CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket);
+ if (pPacketNode) {
+ pXMLTemplateDOMRoot = pElement;
+ pXFARootNode->InsertChild(pPacketNode);
+ }
+ } else {
CXFA_Node* pPacketNode = ParseAsXDPPacket(pElement, ePacket);
if (pPacketNode) {
if (pPacketInfo &&
@@ -486,6 +497,9 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
}
}
}
+ if (!pXMLTemplateDOMRoot) {
+ return NULL;
+ }
if (pXMLDatasetsDOMRoot) {
CXFA_Node* pPacketNode =
ParseAsXDPPacket(pXMLDatasetsDOMRoot, XFA_XDPPACKET_Datasets);
diff --git a/xfa/src/fxfa/src/parser/xfa_parser_imp_embeddertest.cpp b/xfa/src/fxfa/src/parser/xfa_parser_imp_embeddertest.cpp
new file mode 100644
index 0000000000..8bff2f6874
--- /dev/null
+++ b/xfa/src/fxfa/src/parser/xfa_parser_imp_embeddertest.cpp
@@ -0,0 +1,15 @@
+// Copyright 2015 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "../../../../../testing/embedder_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class XFAParserImpEmbeddertest : public EmbedderTest {};
+
+TEST_F(XFAParserImpEmbeddertest, Bug_216) {
+ EXPECT_TRUE(OpenDocument("testing/resources/bug_216.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+ UnloadPage(page);
+} \ No newline at end of file