[ 
https://issues.apache.org/jira/browse/PDFBOX-2102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14014295#comment-14014295
 ] 

Petr Slaby commented on PDFBOX-2102:
------------------------------------

[[email protected]]: After the change in 1598316, I am getting 
IllegalArgumentExceptions on some of the documents in my test suite. The 
culprit seems to be a missing in.position(in.position() - 1); at the line 141 
in SingleByteCharset. You might also consider using something like
int mark = src.position();
try 
{
 mark++; // in front of out.put()
}
finally 
{
src.position(mark);
}

This pattern is used in single byte encoding implementation of OpenJVM. Also, 
it has a better performing implementation for the case that both the byte and 
char buffer are based on an array (which is the most usual case).

The test document (coming from http://www.stillhq.com/pdfdb/db.html) and stack 
trace is attached, but the missing call of position() seems to be obvious, 
anyway.



> Characters swallowed on COSString.getString()
> ---------------------------------------------
>
>                 Key: PDFBOX-2102
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2102
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Parsing
>    Affects Versions: 1.8.5, 1.8.6, 2.0.0
>            Reporter: Jeremias Maerki
>            Assignee: Jeremias Maerki
>             Fix For: 1.8.6, 2.0.0
>
>
> PDFBOX-1437 seems to have introduced a regression that causes characters like 
> \n to be swallowed when COSString.getString() is called. PDFDocEncoding 
> doesn't handle all valid characters.
> {code}
> testStr = "Line1\nLine2\nLine3\n";
> COSString lineFeedString = new COSString(testStr);
> assertEquals(testStr, lineFeedString.getString());
> //Same as previous but this time as a dictionary value
> lineFeedString = new COSString(true);
> for (int i = 0; i < testStr.length(); i++) {
>     lineFeedString.append(testStr.charAt(i));
> }
> assertEquals(testStr, lineFeedString.getString()); //currently fails
> {code}
> Direct link to the change causing the regression:
> http://svn.apache.org/viewvc?view=revision&revision=1406628



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to