Skip to content

Editor: some types of code removed when added in the code shortcode #22432

Closed

Description

Steps to reproduce

  1. Starting at URL: https://wordpress.com/post
  2. Create a new post, and use the [code] shortcode to add this code:
<div data-spotim-module="recirculation" data-spot-id="sp_XXXXXXXX"></div>

<script src="https://randomdomain.com/spot/sp_XXXXXXXX"></script>
<script src="https://randomdomain.com/deferred/bundle.js" data-spotim-module="deferred-launcher" data-spot-id="sp_XXXXXXXX" data-post-id="POST_ID_HERE"></script>
  1. Publish the post.

What I expected

For the published post to display the code exactly as I entered it, but using the syntax highlighter.

What happened instead

All the code was stripped out, and all that appeared in the post were an empty div-tag with no attributes.

edit_post_ kokkiestrialtestsite _wordpress_com

If I leave the editor, and then edit the post again, the code has disappeared from the editor as well...

edit_post_ kokkiestrialtestsite _wordpress_com

...while in the HTML view in the editor the post content has changed to:

<div></div>
<pre>
[/code]

I was also able to replicate this using only an empty div-tag with the draggable and tabindex attributes (did a random spot-check). Using an id and style attribute on an empty div works correctly, so it looks like the attributes might be causing a problem here.

If I tried using only the script tags in the example code they were also stripped out and the published post contained an empty code block.

Changing the syntax highlighter language does not appear to make a difference.

The same code embeds fine if added via the WP-Admin editor, but the moment the post is updated in Calypso the same thing happens.

Context / Source

Reported by a user in 890602-f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions