diff options
-rw-r--r-- | core/fxcrt/css/cfx_css.h | 1 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlparser_unittest.cpp | 101 | ||||
-rw-r--r-- | testing/libfuzzer/pdf_css_fuzzer.cc | 1 | ||||
-rw-r--r-- | xfa/fgas/font/cfgas_fontmgr.h | 1 | ||||
-rw-r--r-- | xfa/fgas/font/cfgas_gefont.h | 1 |
5 files changed, 27 insertions, 78 deletions
diff --git a/core/fxcrt/css/cfx_css.h b/core/fxcrt/css/cfx_css.h index 32f376f327..e9ff722d08 100644 --- a/core/fxcrt/css/cfx_css.h +++ b/core/fxcrt/css/cfx_css.h @@ -7,7 +7,6 @@ #ifndef CORE_FXCRT_CSS_CFX_CSS_H_ #define CORE_FXCRT_CSS_CFX_CSS_H_ -#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxge/fx_dib.h" enum CFX_CSSVALUETYPE { diff --git a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp index 39ddc32987..97a81f7640 100644 --- a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp +++ b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp @@ -13,6 +13,8 @@ #include "testing/test_support.h" #include "third_party/base/ptr_util.h" +namespace { + class CFX_XMLTestParser : public CFX_XMLParser { public: CFX_XMLTestParser(CFX_XMLNode* pParent, @@ -36,6 +38,15 @@ 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); + return stream; +} + +} // namespace + TEST(CFX_XMLParserTest, CData) { const char* input = "<script contentType=\"application/x-javascript\">\n" @@ -51,11 +62,7 @@ TEST(CFX_XMLParserTest, CData) { L" app.alert(\"Tclams\");\n" L" "; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -100,11 +107,7 @@ TEST(CFX_XMLParserTest, CDataWithInnerScript) { L" </script>\n" L" "; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -138,11 +141,7 @@ TEST(CFX_XMLParserTest, ArrowBangArrow) { " <!>\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -174,11 +173,7 @@ TEST(CFX_XMLParserTest, ArrowBangBracketArrow) { " <![>\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -205,11 +200,7 @@ TEST(CFX_XMLParserTest, IncompleteCData) { " <![CDATA>\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -236,11 +227,7 @@ TEST(CFX_XMLParserTest, UnClosedCData) { " <![CDATA[\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -267,11 +254,7 @@ TEST(CFX_XMLParserTest, EmptyCData) { " <![CDATA[]]>\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -305,11 +288,7 @@ TEST(CFX_XMLParserTest, Comment) { " <!-- A Comment -->\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -340,11 +319,7 @@ TEST(CFX_XMLParserTest, IncorrectCommentStart) { " <!- A Comment -->\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -375,11 +350,7 @@ TEST(CFX_XMLParserTest, CommentEmpty) { " <!---->\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -410,11 +381,7 @@ TEST(CFX_XMLParserTest, CommentThreeDash) { " <!--->\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -439,11 +406,7 @@ TEST(CFX_XMLParserTest, CommentTwoDash) { " <!-->\n" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -472,11 +435,7 @@ TEST(CFX_XMLParserTest, Entities) { "�" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -505,11 +464,7 @@ TEST(CFX_XMLParserTest, EntityOverflowHex) { "�" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -538,11 +493,7 @@ TEST(CFX_XMLParserTest, EntityOverflowDecimal) { "�" "</script>"; - RetainPtr<CFX_SeekableStreamProxy> stream = - pdfium::MakeRetain<CFX_SeekableStreamProxy>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique<CFX_XMLNode>(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); diff --git a/testing/libfuzzer/pdf_css_fuzzer.cc b/testing/libfuzzer/pdf_css_fuzzer.cc index 7cd924e70f..4f2f410aa3 100644 --- a/testing/libfuzzer/pdf_css_fuzzer.cc +++ b/testing/libfuzzer/pdf_css_fuzzer.cc @@ -4,7 +4,6 @@ #include <memory> -#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/css/cfx_css.h" #include "core/fxcrt/css/cfx_csssyntaxparser.h" #include "core/fxcrt/fx_string.h" diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h index f4a62847d6..f082b02dd3 100644 --- a/xfa/fgas/font/cfgas_fontmgr.h +++ b/xfa/fgas/font/cfgas_fontmgr.h @@ -14,7 +14,6 @@ #include <utility> #include <vector> -#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/observable.h" #include "core/fxcrt/retain_ptr.h" diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h index 22169d6d3d..2e70fb662f 100644 --- a/xfa/fgas/font/cfgas_gefont.h +++ b/xfa/fgas/font/cfgas_gefont.h @@ -12,6 +12,7 @@ #include <utility> #include <vector> +#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/unowned_ptr.h" |