summaryrefslogtreecommitdiff
path: root/core/fxcrt/xml
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/xml')
-rw-r--r--core/fxcrt/xml/cfx_xmlparser.cpp11
-rw-r--r--core/fxcrt/xml/cfx_xmlparser.h4
-rw-r--r--core/fxcrt/xml/cfx_xmlparser_unittest.cpp12
3 files changed, 17 insertions, 10 deletions
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index 8292b33206..9336c11f87 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -10,6 +10,7 @@
#include <cwctype>
#include <iterator>
+#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/xml/cfx_xmlchardata.h"
@@ -81,10 +82,10 @@ bool CFX_XMLParser::IsXMLNameChar(wchar_t ch, bool bFirstChar) {
}
CFX_XMLParser::CFX_XMLParser(CFX_XMLNode* pParent,
- const RetainPtr<CFX_SeekableStreamProxy>& pStream)
+ const RetainPtr<IFX_SeekableStream>& pStream)
: m_pParent(pParent),
m_pChild(nullptr),
- m_pStream(pStream),
+ m_pStream(pdfium::MakeRetain<CFX_SeekableStreamProxy>(pStream)),
m_iXMLPlaneSize(1024),
m_iCurrentPos(0),
m_iCurrentNodeNum(-1),
@@ -106,6 +107,12 @@ CFX_XMLParser::CFX_XMLParser(CFX_XMLNode* pParent,
ASSERT(m_pParent);
ASSERT(pStream);
+ uint16_t wCodePage = m_pStream->GetCodePage();
+ if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
+ wCodePage != FX_CODEPAGE_UTF8) {
+ m_pStream->SetCodePage(FX_CODEPAGE_UTF8);
+ }
+
m_NodeStack.push(m_pParent);
m_CurNode.iNodeNum = -1;
diff --git a/core/fxcrt/xml/cfx_xmlparser.h b/core/fxcrt/xml/cfx_xmlparser.h
index 02a6ac441f..52d86fb82d 100644
--- a/core/fxcrt/xml/cfx_xmlparser.h
+++ b/core/fxcrt/xml/cfx_xmlparser.h
@@ -19,7 +19,7 @@
class CFX_XMLElement;
class CFX_XMLNode;
-class CFX_SeekableStreamProxy;
+class IFX_SeekableStream;
enum class FX_XmlSyntaxResult {
None,
@@ -44,7 +44,7 @@ class CFX_XMLParser {
static bool IsXMLNameChar(wchar_t ch, bool bFirstChar);
CFX_XMLParser(CFX_XMLNode* pParent,
- const RetainPtr<CFX_SeekableStreamProxy>& pStream);
+ const RetainPtr<IFX_SeekableStream>& pStream);
virtual ~CFX_XMLParser();
bool Parse();
diff --git a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
index 97a81f7640..4bd953df25 100644
--- a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
@@ -6,7 +6,7 @@
#include <memory>
-#include "core/fxcrt/cfx_seekablestreamproxy.h"
+#include "core/fxcrt/cfx_memorystream.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/xml/cfx_xmlnode.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -18,7 +18,7 @@ namespace {
class CFX_XMLTestParser : public CFX_XMLParser {
public:
CFX_XMLTestParser(CFX_XMLNode* pParent,
- const RetainPtr<CFX_SeekableStreamProxy>& pStream)
+ const RetainPtr<IFX_SeekableStream>& pStream)
: CFX_XMLParser(pParent, pStream) {}
~CFX_XMLTestParser() override = default;
@@ -38,10 +38,10 @@ class CFX_XMLTestParser : public CFX_XMLParser {
WideString GetTextData() const { return CFX_XMLParser::GetTextData(); }
};
-RetainPtr<CFX_SeekableStreamProxy> MakeProxy(const char* input) {
- auto stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
+RetainPtr<CFX_MemoryStream> MakeProxy(const char* input) {
+ auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
+ false);
return stream;
}