[Libreoffice-commits] core.git: vcl/source

Felix Wiegand (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 25 20:05:20 UTC 2020


 vcl/source/filter/ipdf/pdfdocument.cxx |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 0d68738d67eacdfebdca3c9183dc11f953b38174
Author:     Felix Wiegand <felix.wiegand at mankido.de>
AuthorDate: Fri Sep 25 09:21:12 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 25 22:04:40 2020 +0200

    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
    
    Change-Id: I68eac4796b182f2632aa1152e58d63c054871581
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103369
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx
index 3c6627f1ce6c..ec763d54a2a1 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -1215,7 +1215,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();
@@ -2189,14 +2190,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;


More information about the Libreoffice-commits mailing list