mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Let Lexer.getObj
return a dummy-Cmd
for commands that start with a non-visible ASCII character (issue 13999)
This way we avoid breaking badly generated PDF documents where a non-visible ASCII character is "glued" to a valid command.
This commit is contained in:
parent
99e442941c
commit
a47844d1fc
4 changed files with 46 additions and 2 deletions
|
@ -13,9 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Cmd, EOF, Name } from "../../src/core/primitives.js";
|
||||
import { Lexer, Linearization, Parser } from "../../src/core/parser.js";
|
||||
import { FormatError } from "../../src/shared/util.js";
|
||||
import { Name } from "../../src/core/primitives.js";
|
||||
import { StringStream } from "../../src/core/stream.js";
|
||||
|
||||
describe("parser", function () {
|
||||
|
@ -217,6 +217,32 @@ describe("parser", function () {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("getObj", function () {
|
||||
it(
|
||||
"should stop immediately when the start of a command is " +
|
||||
"a non-visible ASCII character (issue 13999)",
|
||||
function () {
|
||||
const input = new StringStream("\x14q\nQ");
|
||||
const lexer = new Lexer(input);
|
||||
|
||||
let obj = lexer.getObj();
|
||||
expect(obj instanceof Cmd).toEqual(true);
|
||||
expect(obj.cmd).toEqual("\x14");
|
||||
|
||||
obj = lexer.getObj();
|
||||
expect(obj instanceof Cmd).toEqual(true);
|
||||
expect(obj.cmd).toEqual("q");
|
||||
|
||||
obj = lexer.getObj();
|
||||
expect(obj instanceof Cmd).toEqual(true);
|
||||
expect(obj.cmd).toEqual("Q");
|
||||
|
||||
obj = lexer.getObj();
|
||||
expect(obj).toEqual(EOF);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Linearization", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue