Skip to content

Commit

Permalink
Handle non ASCII characters in PDF name objects (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopding authored Apr 29, 2020
1 parent f7f9304 commit 0bc4f7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/core/parser/PDFObjectParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,7 @@ class PDFObjectParser extends BaseParser {
let name = '';
while (!this.bytes.done()) {
const byte = this.bytes.peek();
if (
byte < CharCodes.ExclamationPoint ||
byte > CharCodes.Tilde ||
IsWhitespace[byte] ||
IsDelimiter[byte]
) {
break;
}
if (IsWhitespace[byte] || IsDelimiter[byte]) break;
name += charFromCode(byte);
this.bytes.next();
}
Expand Down
4 changes: 4 additions & 0 deletions tests/core/parser/PDFObjectParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ describe(`PDFObjectParser`, () => {
expect(parser.parseObject()).toBe(PDFName.of('Bing'));
expect(parser.parseObject()).toBe(PDFName.of('Bang'));
});

it(`handles names containing non-ASCII characters`, () => {
expectParse('/ABCDEE+»ªÎÄÖÐËÎ').toBe(PDFName.of('ABCDEE+»ªÎÄÖÐËÎ'));
});
});

describe(`when parsing arrays`, () => {
Expand Down

0 comments on commit 0bc4f7b

Please sign in to comment.