-
Notifications
You must be signed in to change notification settings - Fork 40
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
UnderscoreJS output escaping improvement? #345
Comments
It looks like |
I would love to have some more code samples for this to work with. I also noticed that the sniff is supposed to check both PHP as well as JS files, but doesn't have a JS test file, so code samples from both would be very very welcome!!! |
Example of what should not raise a violation: function display_foo {
?>
<script id="template" type="text/template">
<li class="dashboard-post-item" dashboard-id="<%= _.escape( id ) %>">
<div class="image-wrapper">
<img src="<%= _.escape( image_url ) %>" class="dashboard-image">
</div>
...
</li>
</script>
<?php
} |
I've done a file search on WPDirectory to find some more code samples and noticed that the |
Question: Undescorejs also supports the normal JS (unsafe) var compiled = _.template("<% print('Hello ' + epithet); %>"); Should this sniff try to detect that as well ? |
@rebeccahum @GaryJones Your input on the above two questions would be much appreciated. |
We could probably exclude gruntfile.js (in the root of the repo, or root of the theme, or root of a plugin?) for all checks. So for this particular check, yes please to excluding it.
Yes please. |
We could add an |
Echoing Gary, yes. |
The Underscorejs output escaping sniff checks for
<%=
, but it's possible that<%= _.escape(...)
would also sufficiently escape the output.I don't know UnderscoreJS, so this needs looking into, but it may help remove some false positives.
The text was updated successfully, but these errors were encountered: