Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
9e3d0f31
Commit
9e3d0f31
authored
Oct 30, 2013
by
Oleg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #14422 and add more thorough check for CSP violations
Close gh-1413
parent
ba2a8fb0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
27 deletions
+35
-27
support.js
src/event/support.js
+8
-5
csp-clean.php
test/data/support/csp-clean.php
+3
-0
csp-log.php
test/data/support/csp-log.php
+3
-0
csp.log
test/data/support/csp.log
+0
-0
csp.php
test/data/support/csp.php
+3
-8
support.js
test/unit/support.js
+18
-14
No files found.
src/event/support.js
View file @
9e3d0f31
...
@@ -4,14 +4,17 @@ define([
...
@@ -4,14 +4,17 @@ define([
(
function
()
{
(
function
()
{
var
i
,
eventName
,
var
i
,
eventName
,
div
=
document
.
createElement
(
"div"
);
div
=
document
.
createElement
(
"div"
);
// Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
// Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
for
(
i
in
{
submit
:
true
,
change
:
true
,
focusin
:
true
})
{
for
(
i
in
{
submit
:
true
,
change
:
true
,
focusin
:
true
})
{
div
.
setAttribute
(
eventName
=
"on"
+
i
,
"t"
)
;
eventName
=
"on"
+
i
;
support
[
i
+
"Bubbles"
]
=
eventName
in
window
||
div
.
attributes
[
eventName
].
expando
===
false
;
if
(
!
(
support
[
i
+
"Bubbles"
]
=
eventName
in
window
)
)
{
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
div
.
setAttribute
(
eventName
,
"t"
);
support
[
i
+
"Bubbles"
]
=
div
.
attributes
[
eventName
].
expando
===
false
;
}
}
}
// Null elements to avoid leaks in IE.
// Null elements to avoid leaks in IE.
...
...
test/data/support/csp-clean.php
0 → 100644
View file @
9e3d0f31
<?php
file_put_contents
(
"csp.log"
,
""
,
LOCK_EX
);
?>
test/data/support/csp-log.php
0 → 100644
View file @
9e3d0f31
<?php
file_put_contents
(
"csp.log"
,
"error"
,
LOCK_EX
);
?>
test/data/support/csp.log
0 → 100755
View file @
9e3d0f31
test/data/support/csp.php
View file @
9e3d0f31
<?php
<?php
# Support: Firefox
# This test page checkes CSP only for browsers with "Content-Security-Policy" header support
header
(
"X-Content-Security-Policy: default-src 'self';"
);
# i.e. no old WebKit or old Firefox
header
(
"Content-Security-Policy: default-src 'self'; report-uri csp-log.php"
);
# Support: Webkit, Safari 5
# http://stackoverflow.com/questions/13663302/why-does-my-content-security-policy-work-everywhere-but-safari
header
(
"X-WebKit-CSP: script-src "
.
$_SERVER
[
"HTTP_HOST"
]
.
" 'self'"
);
header
(
"Content-Security-Policy: default-src 'self'"
);
?>
?>
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
...
...
test/unit/support.js
View file @
9e3d0f31
...
@@ -60,6 +60,24 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -60,6 +60,24 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
strictEqual
(
shrinkWrapBlocks
,
computedSupport
.
shrinkWrapBlocks
,
"jQuery.support.shrinkWrapBlocks properties are the same"
);
strictEqual
(
shrinkWrapBlocks
,
computedSupport
.
shrinkWrapBlocks
,
"jQuery.support.shrinkWrapBlocks properties are the same"
);
});
});
// This test checkes CSP only for browsers with "Content-Security-Policy" header support
// i.e. no old WebKit or old Firefox
testIframeWithCallback
(
"Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions"
,
"support/csp.php"
,
function
(
support
)
{
expect
(
2
);
deepEqual
(
jQuery
.
extend
(
{},
support
),
computedSupport
,
"No violations of CSP polices"
);
stop
();
supportjQuery
.
get
(
"data/support/csp.log"
).
done
(
function
(
data
)
{
equal
(
data
,
""
,
"No log request should be sent"
);
supportjQuery
.
get
(
"data/support/csp-clean.php"
).
done
(
start
);
});
}
);
(
function
()
{
(
function
()
{
var
expected
,
version
,
var
expected
,
version
,
userAgent
=
window
.
navigator
.
userAgent
;
userAgent
=
window
.
navigator
.
userAgent
;
...
@@ -462,17 +480,3 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -462,17 +480,3 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
}
}
})();
})();
// Support: Safari 5.1
// Shameless browser-sniff, but Safari 5.1 mishandles CSP
if
(
!
(
typeof
navigator
!==
"undefined"
&&
(
/ AppleWebKit
\/\d
.*
?
Version
\/(\d
+
)
/
.
exec
(
navigator
.
userAgent
)
||
[])[
1
]
<
6
)
)
{
testIframeWithCallback
(
"Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions"
,
"support/csp.php"
,
function
(
support
)
{
expect
(
1
);
deepEqual
(
jQuery
.
extend
(
{},
support
),
computedSupport
,
"No violations of CSP polices"
);
}
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment