Annotation save fails when the quote prefix or suffix splits a surrogate pair (e.g., next to MathJax 4 math)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
- Ambito
- frontend
Direzione di ricerca
The payload does not name the file, so start by finding where the text-quote selector's 32-code-unit prefix and suffix are cut, then reproduce with the HTML snippet in the issue (highlight consectetur, save). The cut must not leave a lone surrogate, either by moving the boundary one code unit or by slicing on code points. Done when the reproduction saves and a test covers a boundary that falls inside a non-BMP character.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Saving an annotation fails with "Saving annotation failed" when the text-quote selector's prefix or suffix boundary falls in the middle of a non-BMP character, such as a character from the Mathematical Alphanumeric Symbols block.
This happens a lot on pages that use MathJax 4 with CHTML output. MathJax 4 writes each glyph as a DOM text node, and it maps italic variables to Unicode math-italic code points; for example, x becomes 𝑥 (U+1D465). In JavaScript these characters are stored as two code units (a surrogate pair). The prefix and suffix are cut at a fixed 32 code units, so if the cut falls between the two halves, the selector ends up with a lone surrogate. I believe the save fails at that point.
Steps to reproduce
-
Serve this page and open it with the Hypothesis client active:
<!doctype html> <html><head> <script async src="https://hypothes.is/embed.js"></script> </head><body> <p>Lorem ipsum consectetur. Lorem ipsum dolor sit ametus 𝑥 elit.</p> </body></html>(You don't need MathJax to reproduce this; the
𝑥stands in for its output.) -
Highlight
consecteturand click Annotate. -
Enter text and save.
Expected: The annotation saves.
Actual: "Saving annotation failed." The text after the highlight, . Lorem ipsum dolor sit ametus (31 code units), is followed by the two-unit 𝑥, so the 32-unit suffix ends with the lone high surrogate \uD835.
Highlighting the first Lorem ipsum instead saves normally, because its 32-unit suffix ends well before the 𝑥.
Suggested fix
When cutting prefix/suffix, don't split a surrogate pair. Move the boundary by one code unit when it would leave half of a non-BMP character, or cut by code point rather than by code unit.
Impact
On math-heavy pages that use MathJax 4 (e.g., textbooks), many highlights near inline math fail: any selection whose start or end is within 32 code units of an italic variable can be affected.
- Lingua principale
- Mustache
- Stelle
- 743
- Fork
- 227
- Merge medio
- 6m
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hypothesis/client
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
hypothesis/client#7592 ·
-
Common anti-FOUC styling technique hides sidebar with `hypothesis-sidebar {visibility: hidden}`Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
hypothesis/client#7498 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
hypothesis/client#7341 ·
-
accessibility
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
hypothesis/client#7315 ·
-
accessibility
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
hypothesis/client#7314 ·
Tutte le issue di hypothesis/client
Issue simili
-
deepseek good first issue roadmap
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
LibreChat-AI/LibreChat#17915 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
fingerprintjs/fingerprintjs#1235 ·
-
Labor 09 - CSS: fájlnevekAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
storytold/craft-libs#723 ·
I maintainer di solito rispondono entro 1 giorno