Skip to content

Copy post strips "\" characters from post content #46020

@sirreal

Description

@sirreal

Impacted plugin

Jetpack

Quick summary

The "copy post" or "duplicate post" functionality may incorrectly strip the \ character from post content.

This affected character is U+005C Reverse Solidus character or "backslash."

Steps to reproduce

  1. Create a post with content like this:

    <!-- wp:code -->
    <pre class="wp-block-code"><code>\t is a tab</code></pre>
    <!-- /wp:code -->

    That is a Code block with the text \t is a tab.

  2. Save the post.

  3. From the post edit view, click "Duplicate" on the post.

  4. A post is created where the text is now t is a tab:

    <!-- wp:code -->
    <pre class="wp-block-code"><code>t is a tab</code></pre>
    <!-- /wp:code -->
 <!-- wp:code -->
-<pre class="wp-block-code"><code>\t is a tab</code></pre>
+<pre class="wp-block-code"><code>t is a tab</code></pre>
 <!-- /wp:code -->

This seems to happen regularly with the \ character:

  • \t -> t
  • \n -> n
  • \f -> f
  • \\ -> \
  • \9 -> 9
  • \ -> (space)

Note

The reproduction uses a Code block because it's easy to see the characters, but this seems to happen on any content. Text in a Paragraph block will also be affected.

Site owner impact

Fewer than 20% of the total website/platform users

Severity

Minor

What other impact(s) does this issue have?

No response

If a workaround is available, please outline it here.

No response

Platform (Simple and/or Atomic)

No response

Metadata

Metadata

Assignees

Type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions