Skip to content

Commit

Permalink
fix: do not mess up the CSP of the websites (#423, #503)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickyc975 committed Mar 31, 2023
1 parent 413ec14 commit 51eaa6f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/EdgeTranslate/src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,15 @@ chrome.webRequest.onHeadersReceived.addListener(
.replaceAll(
// Remove 'none' and "none".
/((^|;)\s*(default-src|script-src|img-src|connect-src))\s+['"]none['"]/g,
"$1"
"$1 "
)
.replaceAll(
// Add Google Page Translate related domains.
/((^|;)\s*(default-src|script-src|img-src|connect-src))/g,
// The last "\s" is added to prevent matching script-src-attr, script-src-elem, etc..
/((^|;)\s*(default-src|script-src|img-src|connect-src))\s/g,
// eslint-disable-next-line prefer-template
"$1 translate.googleapis.com translate.google.com www.google.com www.gstatic.com " +
chrome.runtime.getURL("")
chrome.runtime.getURL(" ")
),
}
: header
Expand Down

0 comments on commit 51eaa6f

Please sign in to comment.