Skip to content

Commit

Permalink
PDF: Fix parsing of escaped name-object characters
Browse files Browse the repository at this point in the history
Name object names can contain characters escaped by `#` signs, where
the `#` is followed by two hexadecimal values denoting the escaped
character's binary representation.

Prior to this change, the code would shift the first hex. value outside
the range of the byte in which it belonged, and would then also attempt
to interpret the decoded value as being outside of the name object,
possibly delimiting the next PDF object in the file.
  • Loading branch information
david-russo committed Oct 24, 2017
1 parent 55b8586 commit 2eb15a1
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ else if (_state == (State.NAME)) {
int ch1 = readChar ();
int ch2 = readChar ();
// Will throw a PDFException if not hexadecimal:
_ch = (hexValue(ch1) << 8) + hexValue(ch2);
_ch = (hexValue(ch1) << 4) + hexValue(ch2);
}
if (isDelimiter (_ch) || isWhitespace (_ch)) {
else if (isDelimiter (_ch) || isWhitespace (_ch)) {
_state = State.WHITESPACE;
((StringValuedToken) token).setValue(buffer.toString());

Expand Down

0 comments on commit 2eb15a1

Please sign in to comment.