Skip to content

Markdown and plaintext output include HTML entities #535

@MoritzLost

Description

@MoritzLost

Description

Not quite sure if this is working as intended and I'm just missing something, but looks like a bug or oversight to me.

The CKEditor content can be accessed as Markdown or plaintext through the FieldData class. But the output still includes encoded HTML entities. For Markdown this is somewhat reasonable, not sure if that's necessary to prevent injection. But for Plaintext, this doesn't make sense. If you want to output something as plaintext, that means it won't be interpreted as HTML, so the HTML entities will appear as-is on screen.

Steps to reproduce

  1. Enter Foo & Bar in a CKEditor field.
  2. In a template, try to access the value as Markdown or Plaintext:
{{ entry.myCKEditorField }}
{# <p>Foo &amp; Bar</p> #}

{{ entry.myCKEditorField.getMarkdown() }}
{# Foo &amp; Bar #}

{{ entry.myCKEditorField.getPlainText() }}
{# Foo &amp; Bar #}

Additional info

  • CKEditor version: 4.11.1
  • Craft version: 5.9.12
  • PHP version: 8.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions