Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

fix: support text for * transformer#709

Open
jannes-mingram-lendi wants to merge 3 commits intoapostrophecms:mainfrom
jannes-mingram-lendi:patch-1
Open

fix: support text for * transformer#709
jannes-mingram-lendi wants to merge 3 commits intoapostrophecms:mainfrom
jannes-mingram-lendi:patch-1

Conversation

@jannes-mingram-lendi
Copy link

@jannes-mingram-lendi jannes-mingram-lendi commented Sep 2, 2025

Allow text option for * transformer

There seems to be a bug where the text option doesn't work with the "any-tag" option:

const clean = sanitizeHtml("<p>Hello</p>", {
  transformTags: {
    'p': function(tagName, attribs) {
      return {
        tagName: 'p',
        text: 'Some text'
      };
    }
  }
});
// <p>Some text</p>
const clean = sanitizeHtml("<p>Hello</p>", {
  transformTags: {
    '*': function(tagName, attribs) {
      return {
        tagName: tagName,
        text: 'Some text'
      };
    }
  }
});
// expected: <p>Some text</p>
// actual: <p>Hello</p>

This PR fixes the scenario above.

What are the specific steps to test this change?

See examples above

What kind of change does this PR introduce?

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a clear description of the bug it resolves.
    Q: Did you want me to open a defect against the repo first, so I can reference the issue-id?
  • The changelog is updated
  • [N/A] Related documentation has been updated
  • Related tests have been updated

@jannes-mingram-lendi jannes-mingram-lendi marked this pull request as ready for review September 2, 2025 12:18
@jannes-mingram-lendi jannes-mingram-lendi changed the title support text for * transformer fix: support text for * transformer Sep 2, 2025
@stale
Copy link

stale bot commented Feb 26, 2026

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant