hypothesis / hypothesis/client

PDF quote selectors can capture text that is not part of the PDF

Open
#3,737 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Mustache
Stars
730
Forks
224
PR merge metrics
No merged PRs in 30d

Description

I noticed some `TextQuoteSelector` selectors in my local h database that had "Loading annotations..." in the prefix or suffix fields. This text is not part of the document but a placeholder DOM element that the client creates in un-rendered PDF pages to serve as a temporary location to attach highlights to until the page is actually rendered.

Looking at the way that quote selectors are created for PDFs, it is possible that they can include text which is not part of a rendered PDF page: https://github.com/hypothesis/client/blob/b1163c4f7e4eb19c5af0f37beaadc7c886551f69/src/annotator/anchoring/pdf.js#L569

It seems that there is a "buffer" of whitespace in the DOM before and after the text layer elements in the PDF, so that is what gets captured as the prefix if you annotate text at the start of the PDF or the suffix if you annotate text at the end. You can see this if you annotate the "Dummy PDF file" text on https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.