Skip to content

clipboard: fix up html entities being escaped #6396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mimecuvalo
Copy link
Member

followup fix for #6344
because we don't base64 encode anymore, a knock-on effect is that any characters within this html blob gets treated as such. we need to unescape these upon paste.

hat-tip to Phil for the report.

Screenshot 2025-07-04 at 17 40 56

Change type

  • bugfix
  • improvement
  • feature
  • api
  • other

Release notes

  • clipboard: fix up html entities being escaped

@mimecuvalo mimecuvalo requested a review from SomeHats July 4, 2025 16:48
@huppy-bot huppy-bot bot added the bugfix Bug fix label Jul 4, 2025
Copy link

vercel bot commented Jul 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
analytics ✅ Ready (Inspect) Visit Preview Jul 8, 2025 10:29am
examples ✅ Ready (Inspect) Visit Preview Jul 8, 2025 10:29am
1 Skipped Deployment
Name Status Preview Updated (UTC)
tldraw-docs ⬜️ Ignored (Inspect) Visit Preview Jul 8, 2025 10:29am

Comment on lines 358 to 363
json = JSON.parse(
tldrawHtmlComment
.replace(/>/g, '>')
.replace(/&lt;/g, '<')
.replace(/&amp;/g, '&')
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some issues here at the moment:

Image

Looking at the code for actually copying this stuff, it seems like we're not actually explicitly html-encoding these things ourselves. Where does the encoding come from? If we're using a regex here instead of a more robust html escaping system, why were these three chosen? I would have expected to see the reverse of this encoding explicitly happening somewhere

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had a discussion with Alex offline. annoyingly we need to go back to the original revision of this:
https://github.com/tldraw/tldraw/pull/6344/commits
we still need to base64 encode the regular non-assets json.

ugh, this means we need a version 3...

@SomeHats
Copy link
Contributor

SomeHats commented Jul 7, 2025

btw can we sdk + dotcom hotfix this when it's ready?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants