Repository navigation
Decode the stored new-post prompt before using it as a placeholder - #271
Merged
Merged
Conversation
Sites can store the new-post prompt entity-encoded (e.g. What's). The editor used to build the textarea from an HTML string, which decoded it. Since #252 the placeholder is set with .attr(), so the entity showed up literally. Decode it once through a detached <textarea>, which parses its content as text, so markup in the prompt can't create elements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Blocker in Use AI review · |
lancewillett
requested changes
Oct 26, 2026
lancewillett
left a comment
Contributor
There was a problem hiding this comment.
Left a review comment with a few changes before we merge this.
jQuery's .html() appends a string containing <script, <style or <link (or a leading table tag) instead of setting innerHTML, which builds live elements even on a detached <textarea>. Set innerHTML on the textarea directly so its content is always parsed as text, and read it back with .val(). Add a <style> case to the test, which takes jQuery's append path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lancewillett
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
o2Editor.getEditor(), decode the textarea's placeholder before setting it on the editor.tests/qunit/editor.js.o2 saves a custom new-post prompt with
esc_attr()(o2.php,front_side_post_prompt), soWhat'sis stored asWhat's. The editor used to build the textarea from an HTML string, which decoded it. Since #252 the placeholder is set with.attr(), so the editor showsWhat'sliterally. The prompt is now decoded once through a detached<textarea>, which parses its content as text, so markup in a prompt still can't create elements.Testing Instructions
masterthe editor placeholder shows'; on this branch it shows'.npx grunt qunitpasses. The new test fails without the fix.🤖 Generated with Claude Code