Skip to content

Copy to clipboard replaces every apostrophe with a backtick #280

Description

@maboa

What happens

Selecting transcript text and using "Copy to clipboard" mangles apostrophes: a transcript reading There's this other space is copied — and shown in the confirmation dialog — as There`s this other space.

Cause

hyperaudio-lite.js:481, in setupPopover():

this.selectionText = selection.toString().replaceAll("'", "`");

selectionText is used in exactly one place (line 506):

let cbText = `${this.selectionText} ${document.location}`;
navigator.clipboard.writeText(cbText);
document.getElementById("clipboard-text").textContent = cbText;

Both clipboard.writeText() and textContent accept arbitrary strings, so nothing here needs apostrophes escaped.

The substitution looks inherited from js/share-this-clipboard.js, which does the same thing — but there it is necessary, because that sharer builds an inline handler (onclick="…writeText('…')…") in which a raw apostrophe would terminate the string literal. Moving the feature into the library replaced that mechanism with an event listener, and the escaping should have gone with it.

Suggested fix

this.selectionText = selection.toString();

Why it matters

The people most likely to use select-to-copy are quoting speech — journalists, researchers, archivists — and a quotation with backticks for apostrophes is unusable without hand-repair. Since pages load the library unpinned from the CDN, fixing it upstream repairs every transcript already exported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions