Ignore the URLs when checking if inferred links overlap existing LinkAnnotations (PR 19110 follow-up)
*Note:* For the issue mentioned on Matrix it'll obviously still make sense to improve the regular expression to detect more URL edge-cases. However it occurred to me that even once that particular case is fixed there'll always be a risk that inferred links could overlap, and effectively block, the actual LinkAnnotations. Hence this patch removes the URL comparison to ensure that overlapping inferred links will always be ignored.
This commit is contained in:
parent
b4a6b1ba0b
commit
37ef0b4a86
@ -88,4 +88,37 @@ describe("autolinker", function () {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("pr19449.pdf", function () {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("pr19449.pdf", ".annotationLayer", null, null, {
|
||||
docBaseUrl: "http://example.com",
|
||||
enableAutoLinking: true,
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must not add links that overlap even if the URLs are different", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
const linkIds = await page.$$eval(
|
||||
".annotationLayer > .linkAnnotation > a",
|
||||
annotations =>
|
||||
annotations.map(a => a.getAttribute("data-element-id"))
|
||||
);
|
||||
expect(linkIds.length).withContext(`In ${browserName}`).toEqual(1);
|
||||
linkIds.forEach(id =>
|
||||
expect(id)
|
||||
.withContext(`In ${browserName}`)
|
||||
.not.toContain("inferred_link_")
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -276,6 +276,7 @@
|
||||
!pr6531_1.pdf
|
||||
!pr6531_2.pdf
|
||||
!pr7352.pdf
|
||||
!pr19449.pdf
|
||||
!bug900822.pdf
|
||||
!bug1392647.pdf
|
||||
!issue918.pdf
|
||||
|
||||
BIN
test/pdfs/pr19449.pdf
Normal file
BIN
test/pdfs/pr19449.pdf
Normal file
Binary file not shown.
@ -327,7 +327,7 @@ class AnnotationLayerBuilder {
|
||||
for (const annotation of this.#annotations) {
|
||||
if (
|
||||
annotation.annotationType !== AnnotationType.LINK ||
|
||||
annotation.url !== link.url
|
||||
!annotation.url
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -353,6 +353,7 @@ const PDFViewerApplication = {
|
||||
// Set some specific preferences for tests.
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
||||
Object.assign(opts, {
|
||||
docBaseUrl: x => x,
|
||||
enableAltText: x => x === "true",
|
||||
enableAutoLinking: x => x === "true",
|
||||
enableFakeMLManager: x => x === "true",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user