vcl/source/filter/ipdf/pdfdocument.cxx | 9 +++++++++ xmlsecurity/qa/unit/pdfsigning/data/tdf114460.pdf |binary xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx | 2 ++ 3 files changed, 11 insertions(+)
New commits: commit 2e0204bec154e50916d26b4f4e855f7d84235592 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Jan 22 22:12:04 2018 +0100 tdf#114460 vcl: handle nested parentheses in PDF roundtrip The roundtrip of the pdf image failed due to this. (cherry picked from commit f58a16d5987c8e8c16580c514ce0c7b0895b4105) Change-Id: I88a9657e242dd2659f9bf06233e5fcbfeb43ceb5 Reviewed-on: https://gerrit.libreoffice.org/48453 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Michael Stahl <mst...@redhat.com> diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 105800974532..cd6bf4659b87 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -2084,11 +2084,20 @@ bool PDFLiteralStringElement::Read(SvStream& rStream) nPrevCh = ch; rStream.ReadChar(ch); + // Start with 1 nesting level as we read a '(' above already. + int nDepth = 1; OStringBuffer aBuf; while (!rStream.IsEof()) { + if (ch == '(' && nPrevCh != '\\') + ++nDepth; + if (ch == ')' && nPrevCh != '\\') + --nDepth; + + if (nDepth == 0) { + // ')' of the outermost '(' is reached. m_aValue = aBuf.makeStringAndClear(); SAL_INFO("vcl.filter", "PDFLiteralStringElement::Read: m_aValue is '" << m_aValue << "'"); return true; diff --git a/xmlsecurity/qa/unit/pdfsigning/data/tdf114460.pdf b/xmlsecurity/qa/unit/pdfsigning/data/tdf114460.pdf new file mode 100644 index 000000000000..a736e5bb90cd Binary files /dev/null and b/xmlsecurity/qa/unit/pdfsigning/data/tdf114460.pdf differ diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx index 59ff206e2c28..08e41dfc997e 100644 --- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx +++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx @@ -416,6 +416,8 @@ void PDFSigningTest::testTokenize() // File that's intentionally smaller than 1024 bytes. "small.pdf", "tdf107149.pdf", + // Nested parentheses were not handled. + "tdf114460.pdf", }; for (const auto& rName : aNames) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits