etherpad-lite/src/tests
John McLear 72dc94f1b9
fix: bold text retains formatting after copy-paste (#7460)
* fix: bold text retains formatting after copy-paste

When pasting bold (or italic, underline, etc.) text, the browser's
contentEditable engine normalized the pasted DOM before Etherpad's
content collector could extract the formatting. The pasted HTML
contained proper <b> tags, but the browser flattened the nested
ace-line divs and stripped the inline formatting in the process.

Now the paste handler checks clipboard HTML for formatting tags. If
found, it prevents default browser paste, parses the HTML in a
detached DOMParser document, and inserts the nodes directly into the
editor. This preserves the formatting tags for the content collector.

Fixes #5037

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* security: sanitize pasted HTML to prevent XSS via clipboard

Strip dangerous elements (script, style, iframe, object, embed, form,
link, meta) and event handler attributes (onclick, onerror, etc.) from
pasted HTML before inserting into the editor. Also removes javascript:
URLs from href attributes.

DOMParser doesn't execute scripts, but importNode copies all attributes
including event handlers that execute when inserted into the live
document.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 01:58:48 +01:00
..
backend fix: list bugs — indent export, renumber performance, and batching (#7449) 2026-04-05 01:58:27 +01:00
backend-new chore: moved first files to esm (#7061) 2025-08-04 19:59:28 +02:00
container Feat/oauth2 (#6281): Added oauth to API paths 2024-03-26 17:11:24 +01:00
frontend Removed deprecated js files. 2024-08-18 19:22:08 +02:00
frontend-new fix: bold text retains formatting after copy-paste (#7460) 2026-04-05 01:58:48 +01:00
ratelimit Added typescript to etherpad 2024-02-05 21:13:02 +01:00
README.md restructure: move bin/ and tests/ to src/ 2021-02-04 17:15:08 -05:00
settings.json Removed comments in settings test. (#6431) 2024-06-05 21:36:05 +02:00

About this folder: Tests

Before running the tests, start an Etherpad instance on your machine.

Frontend

To run the frontend tests, point your browser to <yourdomainhere>/tests/frontend

Backend

To run the backend tests, run cd src and then npm test