-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for special attribute filtering. #13
base: master
Are you sure you want to change the base?
Conversation
72622cc
to
0022cfd
Compare
@jimmyhchan this could be interesting |
}, | ||
|
||
attrFilters: { | ||
'a[href]': function(val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may have to repeat this key a bunch of times. a[href], img[src]. is there a way to gather a bunch of contexts to filter on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could pretty easily define a single function and then assign it to multiple contexts:
function anchorsAndImages (val) {
...
}
attrFilters: {
'a[href]': anchorsAndImages,
'img[src]': anchorsAndImages
}
I was also thinking of having some more generic rules. For example, 'a'
would match all attributes in an anchor tag, and '[src]'
would match src
attributes on any tag. That leads to a few questions:
- If multiple filters are found for a single attribute, are they all executed or just the most specific?
- If they are all executed, in what order are they executed? From most specific to least specific? Random?
Experimental: Allow attribute values to be filtered before being attached to an element. This should prevent something like: ``` <a href="{customUrl}">Click me</a> ``` from being an XSS hole with a context like: ``` { customUrl: "javascript:alert('hacked')" } ```
So, even with the new compiler, I think we need to put something in the runtime, because we won't know until runtime if attributes with UGC need to be filtered. |
Experimental: Allow attribute values to be filtered before being
attached to an element. This should prevent something like:
from being an XSS hole with a context like: