WICKET-7196 Let a wicket:label tag turn off escaping - #1552
Merged
Conversation
The label text <wicket:label> takes from a model or from a resource bundle is escaped where it is written, and the flag that decides it is read from the TextLabel the resolver inserts. That component is never handed to the application, so its flag stays at the default and nothing can clear it. An application whose bundle holds markup, or an entity such as Save & close, had no way back other than moving the content into the tag body. The tag now carries the decision. An escape attribute sets escapeModelStrings on the label the resolver creates, so the write site is unchanged and the attribute is the markup spelling of the flag the security model already describes: clearing it is the application saying the content is markup and taking responsibility for it. A missing attribute keeps the escaping, and so does an empty one. That differs from <wicket:message>, which reads the same attribute with IValueMap#getBoolean and resolves an empty value to false. There false is the default, here it is the opt-out, so an empty value has to keep the escaping rather than quietly drop it. An unrecognised value still fails, the way it does on <wicket:message>. The attribute says nothing about the tag body. That body is markup the label has just rendered itself, nested components and <wicket:message> included, and is written as is either way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
papegaaij
marked this pull request as ready for review
August 23, 2026 20:48
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.
WICKET-7196
<wicket:label>escapes the label text it takes from a model or from a resource bundle. The flag that decides it is read from theTextLabelthe resolver inserts, and that component is never handed to the application, so nothing can clear it. An application whose bundle holds markup, or an entity such asSave & close, has no way back other than moving the content into the tag body.This adds an
escapeattribute to the tag:It sets
escapeModelStringson the label the resolver creates, so the write site inonComponentTagBodyis unchanged and the attribute is the markup spelling of the flagSECURITY.mdalready describes — clearing it is the application saying the content is markup and taking responsibility for it.Differences from
<wicket:message escape="…">The polarity is inverted: a message is written as markup by default and
escape="true"opts in, while a label is escaped by default andescape="false"opts out.Because of that, a missing or empty attribute keeps the escaping.
<wicket:message>reads the same attribute withIValueMap#getBoolean, which resolves an empty value tofalse; therefalseis the default, here it is the opt-out, so an empty value has to keep the escaping rather than quietly drop it. An unrecognised value still raisesStringValueConversionException, the way it does on<wicket:message>.The attribute says nothing about the tag body. That body is markup the label has just rendered itself, nested components and
<wicket:message>included, and is written as is either way.Tests
New
AutoLabelEscapeAttributeTestcoversescape="false"on all three text sources (label model, default label from the bundle,keyattribute),escape="true"still escaping,escape=""still escaping, an unrecognised value failing the render, and theFormComponent's label still holding the raw bundle value so error messages are unaffected.Full
wicket-core-testssuite passes (2392 tests).🤖 Generated with Claude Code