diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-22 22:12:04 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-23 09:07:38 +0100 |
commit | f58a16d5987c8e8c16580c514ce0c7b0895b4105 (patch) | |
tree | 86b408f576d45bb30729992c225cd61f1f595733 | |
parent | 90ae1e1bbbce7be9b2ff7add75923b1891e65df6 (diff) |
tdf#114460 vcl: handle nested parentheses in PDF roundtrip
The roundtrip of the pdf image failed due to this.
Change-Id: I88a9657e242dd2659f9bf06233e5fcbfeb43ceb5
Reviewed-on: https://gerrit.libreoffice.org/48362
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | vcl/source/filter/ipdf/pdfdocument.cxx | 9 | ||||
-rw-r--r-- | xmlsecurity/qa/unit/pdfsigning/data/tdf114460.pdf | bin | 0 -> 12669 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 6921683d5054..af1eea1f57cf 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -2015,11 +2015,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.eof()) { + 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 Binary files differnew file mode 100644 index 000000000000..a736e5bb90cd --- /dev/null +++ b/xmlsecurity/qa/unit/pdfsigning/data/tdf114460.pdf diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx index b36d926a4a34..cb7fd4cfe945 100644 --- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx +++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx @@ -450,6 +450,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) |