Escape attr.label and attr.value in AppHelper#recent_settings#5490
Open
ddri wants to merge 1 commit into
Open
Conversation
AppHelper#recent_settings builds an HTML string used as Bootstrap popover content rendered with bs_html: 'true'. The label and value fields were interpolated without escaping, allowing unescaped HTML to appear in the popover. Use h() to escape both fields before insertion.
johrstrom
reviewed
May 27, 2026
| def recent_settings(app) | ||
| content = app.attributes.select(&:display?).map do |attr| | ||
| "<div class='row'> <dt>#{attr.label}:</dt> <dd>#{attr.value}</dd> </div>" | ||
| "<div class='row'> <dt>#{h(attr.label)}:</dt> <dd>#{h(attr.value)}</dd> </div>" |
Contributor
There was a problem hiding this comment.
Can you use html_escape instead of h - I know it's an alias, but I just feel like being explicit is better here.
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.
The "Recently Used Apps" widget shows a popover with the settings from your last job submission. The label and value for each setting were inserted into the popover HTML without escaping:
If a label or value contained HTML characters like
<,>, or", they would be rendered as markup instead of displayed as text. Wrapping both withh()escapes them before insertion.Changes
app/helpers/app_helper.rb— escapeattr.labelandattr.valuewithh()before inserting into popover HTMLtest/helpers/app_helper_test.rb— add tests for HTML characters in label and value, nil cases, and safe values (file was previously empty)