mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-18 03:04:07 +02:00
Merge pull request #21080 from calixteman/recursive_glyf
Avoid infinite recursion while compiling a glyph
This commit is contained in:
commit
88abcefea0
@ -168,7 +168,13 @@ function lookupCmap(ranges, unicode) {
|
||||
};
|
||||
}
|
||||
|
||||
function compileGlyf(code, cmds, font) {
|
||||
function compileGlyf(code, cmds, font, visitedGlyphs = new Set()) {
|
||||
if (visitedGlyphs.has(code)) {
|
||||
warn("compileGlyf: skipping recursive composite glyph reference.");
|
||||
return;
|
||||
}
|
||||
|
||||
visitedGlyphs.add(code);
|
||||
function moveTo(x, y) {
|
||||
if (firstPoint) {
|
||||
// Close the current subpath in adding a straight line to the first point.
|
||||
@ -250,7 +256,7 @@ function compileGlyf(code, cmds, font) {
|
||||
// TODO: we must use arg1 and arg2 to make something similar to:
|
||||
// https://github.com/freetype/freetype/blob/edd4fedc5427cf1cf1f4b045e53ff91eb282e9d4/src/truetype/ttgload.c#L1209
|
||||
}
|
||||
compileGlyf(subglyph, cmds, font);
|
||||
compileGlyf(subglyph, cmds, font, visitedGlyphs);
|
||||
cmds.restore();
|
||||
}
|
||||
} while (flags & 0x20);
|
||||
@ -352,6 +358,7 @@ function compileGlyf(code, cmds, font) {
|
||||
startPoint = endPoint + 1;
|
||||
}
|
||||
}
|
||||
visitedGlyphs.delete(code);
|
||||
}
|
||||
|
||||
function compileCharString(charStringCode, cmds, font, glyphId) {
|
||||
|
||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -899,3 +899,4 @@
|
||||
!issue16091.pdf
|
||||
!issue7821.pdf
|
||||
!issue21068.pdf
|
||||
!recursiveCompositGlyf.pdf
|
||||
|
||||
BIN
test/pdfs/recursiveCompositGlyf.pdf
Normal file
BIN
test/pdfs/recursiveCompositGlyf.pdf
Normal file
Binary file not shown.
@ -14105,5 +14105,12 @@
|
||||
"link": true,
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "recursiveCompositGlyf",
|
||||
"file": "pdfs/recursiveCompositGlyf.pdf",
|
||||
"md5": "e4e106d20e4af10d7a5f1a5da02db66f",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
}
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user