summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.h6
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser_unittest.cpp38
3 files changed, 24 insertions, 27 deletions
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 27d80cde15..b126d8267f 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -318,8 +318,9 @@ CXFA_DocumentParser::CXFA_DocumentParser(CXFA_Document* pFactory)
CXFA_DocumentParser::~CXFA_DocumentParser() = default;
-bool CXFA_DocumentParser::Parse(const RetainPtr<IFX_SeekableStream>& pStream,
- XFA_PacketType ePacketID) {
+bool CXFA_DocumentParser::Parse(
+ const RetainPtr<IFX_SeekableReadStream>& pStream,
+ XFA_PacketType ePacketID) {
xml_doc_ = LoadXML(pStream);
if (!xml_doc_)
return false;
@@ -342,7 +343,7 @@ CFX_XMLNode* CXFA_DocumentParser::ParseXMLData(const ByteString& wsXML) {
}
std::unique_ptr<CFX_XMLDocument> CXFA_DocumentParser::LoadXML(
- const RetainPtr<IFX_SeekableStream>& pStream) {
+ const RetainPtr<IFX_SeekableReadStream>& pStream) {
ASSERT(pStream);
CFX_XMLParser parser(pStream);
diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h
index 4e75db935a..064475aee3 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.h
+++ b/xfa/fxfa/parser/cxfa_document_parser.h
@@ -17,14 +17,14 @@
class CXFA_Document;
class CXFA_Node;
class CFX_XMLInstruction;
-class IFX_SeekableStream;
+class IFX_SeekableReadStream;
class CXFA_DocumentParser {
public:
explicit CXFA_DocumentParser(CXFA_Document* pFactory);
~CXFA_DocumentParser();
- bool Parse(const RetainPtr<IFX_SeekableStream>& pStream,
+ bool Parse(const RetainPtr<IFX_SeekableReadStream>& pStream,
XFA_PacketType ePacketID);
CFX_XMLNode* ParseXMLData(const ByteString& wsXML);
@@ -35,7 +35,7 @@ class CXFA_DocumentParser {
private:
std::unique_ptr<CFX_XMLDocument> LoadXML(
- const RetainPtr<IFX_SeekableStream>& pStream);
+ const RetainPtr<IFX_SeekableReadStream>& pStream);
CXFA_Node* ParseAsXDPPacket(CFX_XMLNode* pXMLDocumentNode,
XFA_PacketType ePacketID);
diff --git a/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp b/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
index b150abc3ea..62bd380326 100644
--- a/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
@@ -3,7 +3,8 @@
// found in the LICENSE file.
#include "xfa/fxfa/parser/cxfa_document_parser.h"
-#include "core/fxcrt/cfx_memorystream.h"
+
+#include "testing/fx_string_testhelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -31,16 +32,15 @@ class CXFA_DocumentParserTest : public testing::Test {
};
TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOff) {
- const char* input =
+ static const char input[] =
"<config>\n"
"<?originalXFAVersion http://www.xfa.org/schema/xfa-template/2.7 "
"v2.7-scripting:0 ?>\n"
"</config>";
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();
@@ -49,7 +49,7 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOff) {
}
TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOn) {
- const char* input =
+ static const char input[] =
"<config>\n"
"<?originalXFAVersion http://www.xfa.org/schema/xfa-template/2.7 "
"v2.7-scripting:1 ?>\n"
@@ -57,9 +57,8 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOn) {
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();
@@ -68,16 +67,15 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOn) {
}
TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScope) {
- const char* input =
+ static const char input[] =
"<config>"
"<?acrobat JavaScript strictScoping ?>\n"
"</config>";
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();
@@ -86,16 +84,15 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScope) {
}
TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScopeBad) {
- const char* input =
+ static const char input[] =
"<config>"
"<?acrobat JavaScript otherScoping ?>\n"
"</config>";
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();
@@ -104,7 +101,7 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScopeBad) {
}
TEST_F(CXFA_DocumentParserTest, MultipleXMLInstructions) {
- const char* input =
+ static const char input[] =
"<config>"
"<?originalXFAVersion http://www.xfa.org/schema/xfa-template/2.7 "
"v2.7-scripting:1 ?>\n"
@@ -114,9 +111,8 @@ TEST_F(CXFA_DocumentParserTest, MultipleXMLInstructions) {
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();