Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ajax: Avoid CSP errors in the script transport for async requests#4763

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mgol merged 1 commit intojquery:masterfrommgol:get-script-csp
Aug 25, 2020

Conversation

mgol
Copy link
Member

@mgolmgol commentedJul 29, 2020
edited
Loading

Summary

Until now, the AJAX script transport only used a script tag to load scripts
for cross-domain requests or ones withscriptAttrs set. This commit makes
it also used for all async requests to avoid CSP errors arising from usage
of inline scripts. This also makesjQuery.getScript not trigger CSP errors
as it uses the AJAX script transport under the hood.

For sync requests such a change is impossible and that's whatjQuery._evalUrl
uses. Fixing that is tracked ingh-1895.

The commit also makes other type of requests using the script tag version of the
script transport set its type to "GET", namely async scripts & ones with
scriptAttrs set in addition to the existing cross-domain ones.

Fixesgh-3969

Checklist

aiwaniuk reacted with heart emoji
@mgolmgol self-assigned thisJul 29, 2020
@mgol
Copy link
MemberAuthor

I believe this is not a breaking change. Can we include it in 3.6.0?

Copy link
Member

@dmethvindmethvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

One thing we do lose here is the ability to set XHR stuff like headers on a script request. I would definitely consider that a breaking change but since it's set for 4.0 it's fair game. At the moment though, there doesn't seem to be an easy way to get the old behavior back and use the old transport.


// These types of requests are handled via a script tag
// so force their methods to GET.
if ( s.async || s.crossDomain || s.scriptAttrs ) {
Copy link
Member

@KrinkleKrinkleAug 17, 2020
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Did you optimize this order for gzip compression? If not, I suspect placings.crossDomain first might chop off a byte or two.

Copy link
MemberAuthor

@mgolmgolAug 24, 2020
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I checked various reorderings & what you propose (+ a few others) were the smallest. Smaller by... one byte compared to my original version. 😄

PR updated. +10 bytes now.

@mgolmgol added the Discuss in MeetingReserved for Issues and PRs that anyone would like to discuss in the weekly meeting. labelAug 22, 2020
Copy link
Member

@timmywiltimmywil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM pending Krinkle's comment

@mgol
Copy link
MemberAuthor

Adding theBehavior Change label per@dmethvin's comment:#4763 (review)

Until now, the AJAX script transport only used a script tag to load scriptsfor cross-domain requests or ones with `scriptAttrs` set. This commit makesit also used for all async requests to avoid CSP errors arising from usageof inline scripts. This also makes `jQuery.getScript` not trigger CSP errorsas it uses the AJAX script transport under the hood.For sync requests such a change is impossible and that's what `jQuery._evalUrl`uses. Fixing that is tracked injquerygh-1895.The commit also makes other type of requests using the script tag version of thescript transport set its type to "GET", namely async scripts & ones with`scriptAttrs` set in addition to the existing cross-domain ones.Fixesjquerygh-3969
@mgolmgol removed Discuss in MeetingReserved for Issues and PRs that anyone would like to discuss in the weekly meeting. Needs review labelsAug 25, 2020
@mgolmgol merged commit07a8e4a intojquery:masterAug 25, 2020
@mgolmgol deleted the get-script-csp branchAugust 25, 2020 19:28
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@KrinkleKrinkleKrinkle left review comments

@dmethvindmethvindmethvin left review comments

@timmywiltimmywiltimmywil approved these changes

@mellowaremellowaremelloware approved these changes

@gibson042gibson042Awaiting requested review from gibson042

Assignees

@mgolmgol

Milestone
4.0.0
Development

Successfully merging this pull request may close these issues.

getScript requires 'unsafe-inline' CSP rule
5 participants
@mgol@Krinkle@dmethvin@timmywil@melloware

[8]ページ先頭

©2009-2025 Movatter.jp