diff options
author | Felix Wiegand <felix.wiegand@mankido.de> | 2020-09-25 09:21:12 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-11-04 17:23:20 +0100 |
commit | bca4f51e1bf098e0ebb7361a69a05a96268df98d (patch) | |
tree | f7217db7e76984bf6182579a2d198cfc87da487f | |
parent | 8003d67bc29f36a2c0c37500fe3d2612992c01aa (diff) |
Correctly parse real numbers in PDFs
The current way of parsing real numbers was not conforming to the PDF
standard ([1]), failing to recognize real numbers without a leading
zero, such as .6, or numbers with a leading +.
[1] PDF 1.7 standard, p. 14
(cherry picked from commit 0d68738d67eacdfebdca3c9183dc11f953b38174)
Change-Id: I68eac4796b182f2632aa1152e58d63c054871581
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105296
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | vcl/source/filter/ipdf/pdfdocument.cxx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 009c01f323b6..7d1305fa364c 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -1210,7 +1210,8 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, } default: { - if (rtl::isAsciiDigit(static_cast<unsigned char>(ch)) || ch == '-') + if (rtl::isAsciiDigit(static_cast<unsigned char>(ch)) || ch == '-' || ch == '+' + || ch == '.') { // Numbering object: an integer or a real. auto pNumberElement = new PDFNumberElement(); @@ -2184,14 +2185,15 @@ bool PDFNumberElement::Read(SvStream& rStream) { return false; } - if (!rtl::isAsciiDigit(static_cast<unsigned char>(ch)) && ch != '-' && ch != '.') + if (!rtl::isAsciiDigit(static_cast<unsigned char>(ch)) && ch != '-' && ch != '+' && ch != '.') { rStream.SeekRel(-1); return false; } while (!rStream.eof()) { - if (!rtl::isAsciiDigit(static_cast<unsigned char>(ch)) && ch != '-' && ch != '.') + if (!rtl::isAsciiDigit(static_cast<unsigned char>(ch)) && ch != '-' && ch != '+' + && ch != '.') { rStream.SeekRel(-1); m_nLength = rStream.Tell() - m_nOffset; |