Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCore: Support passing nonce through jQuery.globalEval #4280
Conversation
mgol
added
the
Core
label
Jan 17, 2019
mgol
added this to the 3.4.0 milestone
Jan 17, 2019
mgol
self-assigned this
Jan 17, 2019
This comment has been minimized.
This comment has been minimized.
I'll create docs issue if this gets accepted. |
mgol
added
the
Needs review
label
Jan 17, 2019
mgol
requested a review
from
gibson042
Jan 17, 2019
mgol
referenced this pull request
Jan 17, 2019
Closed
CSP: Provide a way to pass nonce to $.globalEval #4278
This comment has been minimized.
This comment has been minimized.
This is |
mgol
requested review from
dmethvin
and
timmywil
Jan 17, 2019
mgol
force-pushed the
mgol:csp-nonce-globaleval
branch
from
1c422fd
to
0d92506
Jan 17, 2019
This comment has been minimized.
This comment has been minimized.
The biggest question is: is this API OK? Or would you rather see something else? |
gibson042
reviewed
Jan 17, 2019
@@ -238,8 +238,8 @@ jQuery.extend( { | |||
}, | |||
|
|||
// Evaluates a script in a global context | |||
globalEval: function( code ) { | |||
DOMEval( code ); | |||
globalEval: function( code, nonce ) { |
This comment has been minimized.
This comment has been minimized.
gibson042
Jan 17, 2019
Member
I don't like the signature, one could easily imagine a realm parameter occupying that position. And I don't really feel great about an options object here, but maybe that is the best approach. :\
This comment has been minimized.
This comment has been minimized.
mgol
Jan 18, 2019
Author
Member
Makes sense. I was also not quite happy about the signature but it's not a boolean so it's not that bad and I wasn't sure if an object isn't too much (we don't have a lot of APIs with one-prop object params, I think).
The object syntax const is just additional 2 bytes, not bad. Changes here: mgol@e49e3e8.
This comment has been minimized.
This comment has been minimized.
mgol
Jan 18, 2019
•
Author
Member
Another version: mgol@8d9cf5e. Gzipped size is the same as mgol@e49e3e8, minified non-gzipped size is smaller by 7 bytes. And we're losing the getAttribute
hacky check so perhaps that's better.
EDIT: This version is broken as we still need the getAttribute
fallback for non-nonce params. But mgol@e49e3e8 is fine.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mgol
Jan 18, 2019
Author
Member
@timmywil @gibson042 Cool. I updated the PR to use the options object. The old version is at mgol@0d92506 if anyone wanted to have a look.
// via an object. | ||
val = node[ i ] || node.getAttribute && node.getAttribute( i ); | ||
if ( val ) { | ||
script.setAttribute( i, val ); |
This comment has been minimized.
This comment has been minimized.
mgol
force-pushed the
mgol:csp-nonce-globaleval
branch
from
0d92506
to
1ce08f0
Jan 18, 2019
gibson042
approved these changes
Jan 19, 2019
mgol
referenced this pull request
Jan 21, 2019
Open
Core: Document passing nonce through jQuery.globalEval #1123
This comment has been minimized.
This comment has been minimized.
Docs issue: jquery/api.jquery.com#1123 |
mgol commentedJan 17, 2019
•
edited
Summary
Support passing nonce through jQuery.globalEval:
Fixes gh-4278
Ref gh-3541
Ref gh-4269
Checklist
Docs issue: jquery/api.jquery.com#1123