diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-02-14 22:26:00 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-02-17 02:43:45 +0100 |
commit | 4d22e3ce32959d795a90653807c1c19cc9c1838e (patch) | |
tree | 2c643edebb6d967ad38800c05b63de584c1a72ff /vcl/qa | |
parent | 246af1d40ec515fe31ef2ac3375401c3fe284157 (diff) |
Move PICT reader from filter module into VCL
Change-Id: I6d3a28769ff3bffa3970a4ab6ab2384bb0aebbca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111011
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
13 files changed, 94 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/clipping-problem.pct b/vcl/qa/cppunit/graphicfilter/data/pict/clipping-problem.pct Binary files differnew file mode 100644 index 000000000000..37fe66c80f7a --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/clipping-problem.pct diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/fail/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pict/fail/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/fail/.gitignore diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2008-1097-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2008-1097-1.pct Binary files differnew file mode 100644 index 000000000000..73943c9d79b9 --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2008-1097-1.pct diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2012-0277-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2012-0277-1.pct Binary files differnew file mode 100644 index 000000000000..5683a55b5f1d --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2012-0277-1.pct diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2013-2577-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2013-2577-1.pct Binary files differnew file mode 100644 index 000000000000..1e1f6d5b5f05 --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2013-2577-1.pct diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/fail/EDB-19332-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/EDB-19332-1.pct Binary files differnew file mode 100644 index 000000000000..5f8740305076 --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/fail/EDB-19332-1.pct diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/fail/exception-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/exception-1.pct Binary files differnew file mode 100644 index 000000000000..f9cd85a4aece --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/fail/exception-1.pct diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/fail/hang-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/hang-1.pct Binary files differnew file mode 100644 index 000000000000..735ce0aca7f3 --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/fail/hang-1.pct diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/indeterminate/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pict/indeterminate/.gitignore new file mode 100644 index 000000000000..1bdee77373fa --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/indeterminate/.gitignore @@ -0,0 +1,2 @@ +*.pict-* +*.pct-* diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/pass/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pict/pass/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/pass/.gitignore diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/pass/ooo25876-2.pct b/vcl/qa/cppunit/graphicfilter/data/pict/pass/ooo25876-2.pct Binary files differnew file mode 100644 index 000000000000..9807e36f74cb --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/pass/ooo25876-2.pct diff --git a/vcl/qa/cppunit/graphicfilter/data/pict/pass/tdf92789.pct b/vcl/qa/cppunit/graphicfilter/data/pict/pass/tdf92789.pct Binary files differnew file mode 100644 index 000000000000..2d6f0d8848bf --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/data/pict/pass/tdf92789.pct diff --git a/vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx new file mode 100644 index 000000000000..a24f2d324d97 --- /dev/null +++ b/vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> +#include <vcl/FilterConfigItem.hxx> +#include <test/xmltesttools.hxx> +#include <tools/stream.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/graph.hxx> +#include <vcl/metaactiontypes.hxx> + +#include <filter/PictReader.hxx> + +using namespace ::com::sun::star; + +/* Implementation of Filters test */ + +class PictFilterTest + : public test::FiltersTest + , public test::BootstrapFixture + , public XmlTestTools +{ +public: + PictFilterTest() : BootstrapFixture(true, false) {} + + virtual bool load(const OUString &, + const OUString &rURL, const OUString &, + SfxFilterFlags, SotClipboardFormatId, unsigned int) override; + + OUString pictURL() + { + return m_directories.getURLFromSrc(u"/vcl/qa/cppunit/graphicfilter/data/pict/"); + } + + /** + * Ensure CVEs remain unbroken + */ + void testCVEs(); + + void testDontClipTooMuch(); + + CPPUNIT_TEST_SUITE(PictFilterTest); + CPPUNIT_TEST(testCVEs); + CPPUNIT_TEST(testDontClipTooMuch); + CPPUNIT_TEST_SUITE_END(); +}; + +bool PictFilterTest::load(const OUString &, + const OUString &rURL, const OUString &, + SfxFilterFlags, SotClipboardFormatId, unsigned int) +{ + SvFileStream aFileStream(rURL, StreamMode::READ); + Graphic aGraphic; + return ImportPictGraphic(aFileStream, aGraphic); +} + +void PictFilterTest::testCVEs() +{ +#ifndef DISABLE_CVE_TESTS + testDir(OUString(), pictURL()); +#endif +} + +void PictFilterTest::testDontClipTooMuch() +{ + SvFileStream aFileStream(pictURL() + "clipping-problem.pct", StreamMode::READ); + GDIMetaFile aGDIMetaFile; + ReadPictFile(aFileStream, aGDIMetaFile); + + MetafileXmlDump dumper; + dumper.filterAllActionTypes(); + dumper.filterActionType(MetaActionType::CLIPREGION, false); + xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + + CPPUNIT_ASSERT (pDoc); + + assertXPath(pDoc, "/metafile/clipregion[5]", "top", "0"); + assertXPath(pDoc, "/metafile/clipregion[5]", "left", "0"); + assertXPath(pDoc, "/metafile/clipregion[5]", "bottom", "empty"); + assertXPath(pDoc, "/metafile/clipregion[5]", "right", "empty"); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(PictFilterTest); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |