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

Special symbols in code block is converted #374

Open
jencijanos opened this issue Jul 23, 2024 · 1 comment
Open

Special symbols in code block is converted #374

jencijanos opened this issue Jul 23, 2024 · 1 comment

Comments

@jencijanos
Copy link

Describe the bug

Symbols such as >, <, and " are converted to their ampersand variants when used inside a code block, but they remain unchanged when outside a code block

To reproduce

I create a post and publish it. After I press publish &gt; and &lt; get’s immediately converted to > and < in the original markdown text. The markdown text was not saved correctly to the database. See "Additional context"

Expected behavior

I expect keep original text inside code blocks.

Screenshots

Visual changes after publish

before publish
after post is published

Data stored in DB

markdown text in database

Server environment

  • Ubuntu 22.04
  • Wordpress 6.6
  • WP Githuber MD plugin Version 1.16.3
  • PHP 8.1.2-1ubuntu2.18

Clean install, no other plugins or special settings applied.

User environment

  • OS: macOS Monterey 12.7.5
  • Browser Safari 17.5, Chrome 126.0.6478.183

Additional context

Data from DB post_content_filtered

i want to keep what i write

one symbol > or "amp" representation &gt;

one symbol < or "amp" representation &lt;

```
one symbol &gt; or &quot;amp&quot; representation &gt;
&lt;title&gt;
```

Expected markdown text

i want to keep what i write

one symbol > or "amp" representation &gt;

one symbol < or "amp" representation &lt;

```
one symbol > or "amp" representation &gt;
<title>
```
@jencijanos
Copy link
Author

Example:

Input markdown text:

~~~
({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&apos;'
}
[tag])
~~~

After Publis post in /wp-admin/post.php $_REQUEST['content'] i see:

~~~\r\n({\r\n\\'&\\': \\'&amp;\\',\r\n\\'<\\': \\'&lt;\\',\r\n\\'>\\': \\'&gt;\\',\r\n\\'\\"\\': \\'&quot;\\',\r\n\\"\\'\\": \\'&apos;\\'\r\n}\r\n[tag])\r\n~~~\r\n

And in wp-githuber-md/src/Controllers/Markdown.php function wp_insert_post_data the $post_data['post_content'] contain:

~~~\r\n({\r\n&#039;&amp;&#039;: &#039;&amp;&#039;,\r\n&#039;&lt;&#039;: &#039;&lt;&#039;,\r\n&#039;&gt;&#039;: &#039;&gt;&#039;,\r\n&#039;&quot;&#039;: &#039;&quot;&#039;,\r\n&quot;&#039;&quot;: &#039;&amp;apos;&#039;\r\n}\r\n[tag])\r\n~~~\r\n

The > symbol converted to &gt; but "&gt;" entity isn't changed, not converted to &amp;gt;. Same situation with other symbols

I don't know where these changes happen, but maybe outside the plugin

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

No branches or pull requests

1 participant