Skip to content

Commit

Permalink
CSP: Fixed directives (#2461)
Browse files Browse the repository at this point in the history
  • Loading branch information
edukisto authored Jul 5, 2020
1 parent dfa5498 commit 537a9e8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/prism-csp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Prism.languages.csp = {
'directive': {
pattern: /\b(?:(?:base-uri|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox) |(?:block-all-mixed-content|disown-opener|upgrade-insecure-requests)(?: |;)|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src )/i,
pattern: /\b(?:base-uri|block-all-mixed-content|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src|disown-opener|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox|upgrade-insecure-requests)\b/i,
alias: 'keyword'
},
'safe': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-csp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/languages/csp/directive_no_value_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ upgrade-insecure-requests;
----------------------------------------------------

[
["directive", "upgrade-insecure-requests;"]
["directive", "upgrade-insecure-requests"],
";"
]

----------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ script-src example.com;
----------------------------------------------------

[
["directive", "script-src "],
"example.com;"
["directive", "script-src"],
" example.com;"
]

----------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/languages/csp/safe_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ default-src 'none'; style-src 'self' 'strict-dynamic' 'nonce-yeah' 'sha256-EpOpN
----------------------------------------------------

[
["directive", "default-src "],
["directive", "default-src"],
["safe", "'none'"],
"; ",
["directive", "style-src "],
["directive", "style-src"],
["safe", "'self'"],
["safe", "'strict-dynamic'"],
["safe", "'nonce-yeah'"],
Expand Down
2 changes: 1 addition & 1 deletion tests/languages/csp/unsafe_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ script-src 'unsafe-inline' 'unsafe-eval' 'unsafe-hashed-attributes';
----------------------------------------------------

[
["directive", "script-src "],
["directive", "script-src"],
["unsafe", "'unsafe-inline'"],
["unsafe", "'unsafe-eval'"],
["unsafe", "'unsafe-hashed-attributes'"],
Expand Down

0 comments on commit 537a9e8

Please sign in to comment.