1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 23:28:06 +02:00

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

@ -0,0 +1 @@
http://web.archive.org/web/20151126121615/http://www.inf.ufg.br/~hugoribeiro/OSPs/osp-im.pdf

View file

@ -817,6 +817,15 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue6692",
"file": "pdfs/issue6692.pdf",
"md5": "ba078e0ddd59cda4b6c51ea10599f49a",
"link": true,
"rounds": 1,
"firstPage": 11,
"lastPage": 11,
"type": "eq"
},
{ "id": "devicen",
"file": "pdfs/devicen.pdf",
"md5": "aac6a91725435d1376c6ff492dc5cb75",

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() {