mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +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:
parent
a8279f7d60
commit
995e1a45b8
4 changed files with 42 additions and 4 deletions
|
@ -832,17 +832,32 @@ var Lexer = (function LexerClosure() {
|
|||
return strBuf.join('');
|
||||
},
|
||||
getName: function Lexer_getName() {
|
||||
var ch;
|
||||
var ch, previousCh;
|
||||
var strBuf = this.strBuf;
|
||||
strBuf.length = 0;
|
||||
while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
|
||||
if (ch === 0x23) { // '#'
|
||||
ch = this.nextChar();
|
||||
if (specialChars[ch]) {
|
||||
warn('Lexer_getName: ' +
|
||||
'NUMBER SIGN (#) should be followed by a hexadecimal number.');
|
||||
strBuf.push('#');
|
||||
break;
|
||||
}
|
||||
var x = toHexDigit(ch);
|
||||
if (x !== -1) {
|
||||
var x2 = toHexDigit(this.nextChar());
|
||||
previousCh = ch;
|
||||
ch = this.nextChar();
|
||||
var x2 = toHexDigit(ch);
|
||||
if (x2 === -1) {
|
||||
error('Illegal digit in hex char in name: ' + x2);
|
||||
warn('Lexer_getName: Illegal digit (' +
|
||||
String.fromCharCode(ch) +') in hexadecimal number.');
|
||||
strBuf.push('#', String.fromCharCode(previousCh));
|
||||
if (specialChars[ch]) {
|
||||
break;
|
||||
}
|
||||
strBuf.push(String.fromCharCode(ch));
|
||||
continue;
|
||||
}
|
||||
strBuf.push(String.fromCharCode((x << 4) | x2));
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue