fix: escape single quotes in HTML filter#337
Draft
Koan-Bot wants to merge 1 commit intoabw:masterfrom
Draft
Conversation
Single quotes were not escaped by the HTML filter or HTML plugin's escape method, creating XSS risk in single-quoted HTML attributes. Uses &abw#39; (numeric entity) which is valid across all HTML versions, unlike ' which is only defined in XML. The xml_filter already handled single quotes via ' — its comment is updated to clarify the distinction. Test coverage added for both filter.t, html.t and vmethods/text.t. Co-Authored-By: Kōan <koan-bot@users.noreply.github.com>
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.
Summary
'→') tohtml_filter()inTemplate::Filtersandescape()inTemplate::Plugin::HTML'(numeric entity) which is valid across all HTML versions, unlike'which is only defined in XMLxml_filteralready handled single quotes via'— its comment is updated to clarify the distinctionSecurity context
Without this fix, template output inserted into single-quoted HTML attributes (e.g.
<div title='[% var | html %]'>) could break out of the attribute and inject arbitrary HTML/JS.Test plan
t/filter.t(double-quote test now also expects escaped single quotes)t/filter.tcovering mixed dangerous characterst/html.tforHTML.escape()with single quotes in attribute contextt/vmethods/text.texpected output for.htmlvmethodxml_filterstill uses'(XML named entity) — no regression🤖 Generated with Claude Code