Skip to content
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

core/file copy paste filename should be escaped #54820

Closed
timotheemoulin opened this issue Sep 26, 2023 · 0 comments · Fixed by #56508
Closed

core/file copy paste filename should be escaped #54820

timotheemoulin opened this issue Sep 26, 2023 · 0 comments · Fixed by #56508
Assignees
Labels
[Block] File Affects the File Block [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@timotheemoulin
Copy link

Description

When adding a new block core/file and editing the file name from Gutenberg, we are allowed to copy/paste HTML instead of text.

image
Here for example, I copied a link from a web page and my browser (Chrome, Edge) copied the full HTML and not only the text of the link.
When I paste it in my file block, the full HTML is pasted instead of the text.

Step-by-step reproduction instructions

  • Create a new Gutenberg page
  • Add a file block
  • Upload any kind of document (media library or upload)
  • Copy a link from any web page
  • Paste it as the file "text"
  • Save the page and reload
  • The block is now broken because it is not supposed to have link inside the "text" attribute

Screenshots, screen recording, code snippet

Here is the block after pasting the HTML link instead of text.

<!-- wp:file {"id":840,"href":"https://my-website.localhost/files/my-file.pdf"} -->
<div class="wp-block-file"><a id="wp-block-file--media-9053007f-ff4e-4ed5-a41b-0c522ca93c8c" href="https://my-website.localhost/files/my-file.pdf" target="_blank" rel="noreferrer noopener"><a rel="nofollow" style="box-sizing: border-box; background-color: rgb(13, 17, 23); color: var(--fgColor-accent, var(--color-accent-fg)); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; white-space-collapse: collapse;" href="https://hackerone.com/wordpress">https://hackerone.com/wordpress</a></a><a href="https://my-website.localhost/files/my-file.pdf" class="wp-block-file__button wp-element-button" download aria-describedby="wp-block-file--media-9053007f-ff4e-4ed5-a41b-0c522ca93c8c">Télécharger</a></div>
<!-- /wp:file -->

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Mamaduka Mamaduka added the [Block] File Affects the File Block label Sep 26, 2023
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Sep 27, 2023
@t-hamano t-hamano self-assigned this Nov 24, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] File Affects the File Block [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants