Skip to content

Commit

Permalink
PDFBOX-5025: Unread trailing e in numbers, by Cody Wayne Holmes; closes
Browse files Browse the repository at this point in the history
#91

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922732 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Dec 29, 2024
1 parent 1abe8ca commit 789eaad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,15 @@ private COSNumber parseCOSNumber() throws IOException
{
source.rewind(1);
}

// PDFBOX-5025: catch "74191endobj"
char lastc = buf.charAt(buf.length() - 1);
if (lastc == 'e' || lastc == 'E')
{
buf.deleteCharAt(buf.length() - 1);
source.rewind(1);
}

return COSNumber.get(buf.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import java.net.URISyntaxException;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline;
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;
import org.apache.pdfbox.rendering.PDFRenderer;
Expand Down Expand Up @@ -348,4 +350,20 @@ void testPDFBox4490() throws IOException
}
}

/**
* PDFBOX-5025: Test for "74191endobj"
*
* @throws IOException
*/
@Test
void testPDFBox5025() throws IOException
{
try (PDDocument doc = Loader.loadPDF(new File(TARGETPDFDIR, "PDFBOX-5025.pdf")))
{
assertEquals(1, doc.getNumberOfPages());
PDFont font = doc.getPage(0).getResources().getFont(COSName.getPDFName("F1"));
int length1 = font.getFontDescriptor().getFontFile2().getCOSObject().getInt(COSName.LENGTH1);
assertEquals(74191, length1);
}
}
}

0 comments on commit 789eaad

Please sign in to comment.