Why does HTML entities are still encoded in Code Block?

In the Code Block if I type in reversed character, they are encoded to HTML entities:

  • Input:

  • Output:

    pre class=wp-block-codecode'#91;] /code/pre
    

Meanwhile, if I put them in the custom HTML block, the output characters aren't encode:

  • Input:

  • Output:

    code'[]/code
    code class='[]/code
    codecode class='[]/code/code
    pre class=wp-block-codecode'[]/code/pre
    

I wonder why this should be the case? I enable troubleshooting mode and use the Twenty Twenty-One theme.

Related: Why does the custom HTML block not preserve the HTML characters?

Topic htmlspecialchars-decode code Wordpress

Category Web


The Code Block is to display things just as you typed them, so it may encode to ensure no code actually executes.

The HTML block is the reverse - it is to execute code exactly as you typed it, so it doesn't encode.

This is intentional, so you can either show or execute code, depending on your needs. :)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.