Problem/Motivation

AceFilter::process() runs html_entity_decode() over the whole filtered text before it looks for any tag, then returns that transformed text. A text filter should only change the part it owns - the code inside an ... tag - and leave every other character exactly as the previous filters produced it. Decoding the entire string changes text that does not belong to this filter, which can turn intentionally entity-encoded characters produced by an earlier filter back into raw markup.

Steps to reproduce

  1. Use a text format that runs the Ace Filter.
  2. Enter body text containing entity-encoded characters outside any tag, e.g. <div>.
  3. The rendered output shows <div> as raw markup instead of the literal text the author entered.

Proposed resolution

  • Do not decode the whole text. Match the tags on the text as received.
  • Decode only the extracted snippet content, which is handed to Ace as text through editor.getSession().setValue(), never as markup.
  • Add kernel coverage: encoded markup outside a tag is returned unchanged; encoded content inside a tag is decoded for the editor.

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ✅ Testing to ensure no regression
  • ✅ Automated unit/functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ❌ Reviewed by a human
  • ❌ Code review by maintainers
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ❌ Update Release Notes
  • ❌ Release

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • The Ace Filter now transforms only the code inside tags and leaves the surrounding text unchanged.

Issue fork ace_editor-3618887

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

  • rajab natshah committed 19066a4e on 2.0.x
    fix: #3618887 Transform only the code inside <ace> tags, leave...
rajab natshah’s picture

Status: Needs review » Fixed

Fixed on 2.0.x: the filter transforms only the code inside tags and leaves the surrounding text as received.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

rajab natshah’s picture

Issue tags: +ace_editor-2.0.4

✅ Released ace_editor-2.0.4

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.