Conversation
|
The goal is to escape things like |
|
Good point!
So for some attributes (like |
|
The href attribute is indeed a bit special due to links allowing to execute JS |
|
Even with
{% set attr = "javascript:alert(1)" %}
<a href="{{ attr|e('html_attr') }}">Click</a>will result in: <a href="javascript:alert(1)">Click</a>(https://twigfiddle.com/n1rbba) This is still executable javascript: https://jsfiddle.net/9ekxLy6u/ So I'm still not sure whether the Could also be relevant for #3760. |
e97d0c2 to
543f28c
Compare
|
I am not using Vue.js myself, so I cannot tell for sure, but according to https://v2.vuejs.org/v2/guide/syntax.html#v-bind-Shorthand this might not only affect The HTML 5 spec does not exclude all those characters from attribute names (https://html.spec.whatwg.org/multipage/syntax.html#attributes-2). XML processors will treat the colon as the XML namespace separator. HTML 5 allows XML only on SVG and MathML elements, and only for pre-defined namespace-prefixes (https://developer.mozilla.org/en-US/docs/Web/API/Attr/localName#:~:text=That%20means%20that%20the%20local,different%20from%20the%20qualified%20name). For other According to https://engine.sygnal.com/research/html5-attribute-names, all current browser implementations handle at least the colon fine, and the aforementioned Vue.js documentation suggests that this is also the case for So, if we'd want to support this, I think it should at least be introduced in a BC way, i. e. with a new escaping strategy name that lets users opt into the new mode with less escaped characters. |
Is it necessary to escape the
:inhtml_attrcontext?For example in this code:
{% for key, value in attributes %} {{ key|escape('html_attr') }}="{{ value }}" {% endfor %}I think it should be allowed to use attribute keys like
v-on:submit.prevent.