-
Notifications
You must be signed in to change notification settings - Fork 383
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
Sanitize scripts without type #898
Comments
Plugins that add scripts to Is this still an issue in 0.6.0? If so, could you please share a PHP snippet that can be used to reproduce the problem? |
Yes, plugins that add scripts to the_content. It's not fixed in 0.6. What it's fixed in 0.6 it's that scripts with type="text/javascript" are sanitized. Here the problems are with scripts with no type specified. As specified in https://dev.w3.org/html5/spec-preview/the-script-element.html#attr-script-type :
So we should sanitize when no type it's specified. Example of php snippet:
|
@eduardcotmrf I'm trying to reproduce the issue but I'm not able to. I think the problem is that your In both the add_filter( 'the_content', function ( $content ) {
return $content . "<script>document.write('no type!');</script><script type='text/javascript'>document.write('with type!');</script>";
} ); Both script tags get removed. Note that in |
Ok, thanks @westonruter . The echo comes from a plugin that we don't have control on it and it's messing up things with our own. When 0.7 it's out, with the output-buffered sanitization, I'll try it again to be sure we don't have this problem anymore. Thanks! |
Related to this issue: #883.
I've encoutered some plugins (for instance custom plugins that add script advertisement tags in the body ) that forget to put the type="text/javascript" in the tag script. In this cases the script it's not removed by amp-wp so the AMP page remains invalid.
Maybe it would be a good idea to sanitize all scripts without any type as well?
At the end we only want to preserve the ones that use type='aplication/json'.
The text was updated successfully, but these errors were encountered: