| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 7 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
| 8 | 8 |
| 9 #include "xfa/fde/xml/fde_xml_imp.h" | 9 #include "xfa/fde/xml/fde_xml_imp.h" |
| 10 #include "xfa/fgas/crt/fgas_codepage.h" | 10 #include "xfa/fgas/crt/fgas_codepage.h" |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 static_cast<CFDE_XMLElement*>(pXMLDocumentNode) | 673 static_cast<CFDE_XMLElement*>(pXMLDocumentNode) |
| 674 ->RemoveAttribute(L"xmlns:xfa"); | 674 ->RemoveAttribute(L"xmlns:xfa"); |
| 675 } | 675 } |
| 676 pDataElement->InsertChildNode(pXMLDocumentNode); | 676 pDataElement->InsertChildNode(pXMLDocumentNode); |
| 677 pDataXMLNode = pDataElement; | 677 pDataXMLNode = pDataElement; |
| 678 } | 678 } |
| 679 if (pDataXMLNode) { | 679 if (pDataXMLNode) { |
| 680 CXFA_Node* pNode = | 680 CXFA_Node* pNode = |
| 681 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); | 681 m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); |
| 682 if (!pNode) { | 682 if (!pNode) { |
| 683 if (pDataXMLNode != pXMLDocumentNode) { | 683 if (pDataXMLNode != pXMLDocumentNode) |
| 684 pDataXMLNode->Release(); | 684 delete pDataXMLNode; |
| 685 } | 685 return nullptr; |
| 686 return NULL; | |
| 687 } | 686 } |
| 688 CFX_WideString wsLocalName; | 687 CFX_WideString wsLocalName; |
| 689 static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName(wsLocalName); | 688 static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName(wsLocalName); |
| 690 pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); | 689 pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName); |
| 691 if (!DataLoader(pNode, pDataXMLNode, TRUE)) { | 690 if (!DataLoader(pNode, pDataXMLNode, TRUE)) { |
| 692 return NULL; | 691 return NULL; |
| 693 } | 692 } |
| 694 pNode->SetXMLMappingNode(pDataXMLNode); | 693 pNode->SetXMLMappingNode(pDataXMLNode); |
| 695 if (pDataXMLNode != pXMLDocumentNode) { | 694 if (pDataXMLNode != pXMLDocumentNode) { |
| 696 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); | 695 pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 if (pXMLInstruction->GetData(0, wsData) && | 1327 if (pXMLInstruction->GetData(0, wsData) && |
| 1329 wsData == FX_WSTRC(L"JavaScript")) { | 1328 wsData == FX_WSTRC(L"JavaScript")) { |
| 1330 if (pXMLInstruction->GetData(1, wsData) && | 1329 if (pXMLInstruction->GetData(1, wsData) && |
| 1331 wsData == FX_WSTRC(L"strictScoping")) { | 1330 wsData == FX_WSTRC(L"strictScoping")) { |
| 1332 pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); | 1331 pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, TRUE); |
| 1333 } | 1332 } |
| 1334 } | 1333 } |
| 1335 } | 1334 } |
| 1336 } | 1335 } |
| 1337 void CXFA_SimpleParser::CloseParser() { | 1336 void CXFA_SimpleParser::CloseParser() { |
| 1338 if (m_pXMLDoc) { | 1337 delete m_pXMLDoc; |
| 1339 m_pXMLDoc->Release(); | 1338 m_pXMLDoc = nullptr; |
| 1340 m_pXMLDoc = NULL; | |
| 1341 } | |
| 1342 if (m_pStream) { | 1339 if (m_pStream) { |
| 1343 m_pStream->Release(); | 1340 m_pStream->Release(); |
| 1344 m_pStream = NULL; | 1341 m_pStream = nullptr; |
| 1345 } | 1342 } |
| 1346 } | 1343 } |
| 1347 | 1344 |
| 1348 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) | 1345 CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) |
| 1349 : m_nodeParser(NULL, TRUE), m_pNotify(pNotify), m_pDocument(NULL) {} | 1346 : m_nodeParser(NULL, TRUE), m_pNotify(pNotify), m_pDocument(NULL) {} |
| 1350 CXFA_DocumentParser::~CXFA_DocumentParser() { | 1347 CXFA_DocumentParser::~CXFA_DocumentParser() { |
| 1351 CloseParser(); | 1348 CloseParser(); |
| 1352 } | 1349 } |
| 1353 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, | 1350 int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, |
| 1354 XFA_XDPPACKET ePacketID) { | 1351 XFA_XDPPACKET ePacketID) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 m_dwCurrentCheckStatus(0), | 1400 m_dwCurrentCheckStatus(0), |
| 1404 m_pRoot(pRoot), | 1401 m_pRoot(pRoot), |
| 1405 m_pStream(pStream), | 1402 m_pStream(pStream), |
| 1406 m_pParser(nullptr), | 1403 m_pParser(nullptr), |
| 1407 m_pParent(pRoot), | 1404 m_pParent(pRoot), |
| 1408 m_pChild(nullptr), | 1405 m_pChild(nullptr), |
| 1409 m_NodeStack(16), | 1406 m_NodeStack(16), |
| 1410 m_syntaxParserResult(FDE_XmlSyntaxResult::None) { | 1407 m_syntaxParserResult(FDE_XmlSyntaxResult::None) { |
| 1411 ASSERT(m_pParent && m_pStream); | 1408 ASSERT(m_pParent && m_pStream); |
| 1412 m_NodeStack.Push(m_pParent); | 1409 m_NodeStack.Push(m_pParent); |
| 1413 m_pParser = new CFDE_XMLSyntaxParser; | 1410 m_pParser.reset(new CFDE_XMLSyntaxParser); |
| 1414 m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); | 1411 m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); |
| 1415 } | 1412 } |
| 1413 |
| 1416 CXFA_XMLParser::~CXFA_XMLParser() { | 1414 CXFA_XMLParser::~CXFA_XMLParser() { |
| 1417 if (m_pParser) { | |
| 1418 m_pParser->Release(); | |
| 1419 } | |
| 1420 m_NodeStack.RemoveAll(); | 1415 m_NodeStack.RemoveAll(); |
| 1421 m_ws1.clear(); | 1416 m_ws1.clear(); |
| 1422 m_ws2.clear(); | 1417 m_ws2.clear(); |
| 1423 } | 1418 } |
| 1419 |
| 1424 int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { | 1420 int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { |
| 1425 if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) | 1421 if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) |
| 1426 return -1; | 1422 return -1; |
| 1427 if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) | 1423 if (m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) |
| 1428 return 100; | 1424 return 100; |
| 1429 | 1425 |
| 1430 int32_t iCount = 0; | 1426 int32_t iCount = 0; |
| 1431 while (TRUE) { | 1427 while (TRUE) { |
| 1432 m_syntaxParserResult = m_pParser->DoSyntaxParse(); | 1428 m_syntaxParserResult = m_pParser->DoSyntaxParse(); |
| 1433 switch (m_syntaxParserResult) { | 1429 switch (m_syntaxParserResult) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 } | 1552 } |
| 1557 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { | 1553 if (pPause && iCount > 500 && pPause->NeedToPauseNow()) { |
| 1558 break; | 1554 break; |
| 1559 } | 1555 } |
| 1560 } | 1556 } |
| 1561 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || | 1557 return (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || |
| 1562 m_NodeStack.GetSize() != 1) | 1558 m_NodeStack.GetSize() != 1) |
| 1563 ? -1 | 1559 ? -1 |
| 1564 : m_pParser->GetStatus(); | 1560 : m_pParser->GetStatus(); |
| 1565 } | 1561 } |
| OLD | NEW |