Ensure that Lexer_getName does not fail if a Name contains in invalid usage of the NUMBER SIGN (#) (issue 6692)

*This is a regression from PR 3424.*

The PDF file in the referenced issue is using `Type3` fonts. In one of those, the `/CharProcs` dictionary contains an entry with the name `/#`. Before the changes to `Lexer_getName` in PR 3424, we were allowing certain invalid `Name` patterns containing the NUMBER SIGN (#).

It's unfortunate that this has been broken for close to two and a half years before the bug surfaced, but it should at least indicate that this is not a widespread issue.

Fixes 6692.
This commit is contained in:
Jonas Jenwald 2015-11-26 13:27:12 +01:00
parent a8279f7d60
commit 995e1a45b8
4 changed files with 42 additions and 4 deletions

View file

@ -1,4 +1,4 @@
/* globals expect, it, describe, StringStream, Lexer, Linearization */
/* globals expect, it, describe, StringStream, Lexer, Name, Linearization */
'use strict';
@ -77,6 +77,19 @@ describe('parser', function() {
expect(result).toEqual('ABCD');
});
it('should handle Names with invalid usage of NUMBER SIGN (#)', function() {
var inputNames = ['/# 680 0 R', '/#AQwerty', '/#A<</B'];
var expectedNames = ['#', '#AQwerty', '#A'];
for (var i = 0, ii = inputNames.length; i < ii; i++) {
var input = new StringStream(inputNames[i]);
var lexer = new Lexer(input);
var result = lexer.getName();
expect(result).toEqual(Name.get(expectedNames[i]));
}
});
});
describe('Linearization', function() {