MM-24780: Fix subpath CSP rewriting after Rudder addition. (#14459)

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
George Goldberg
2020-05-05 09:19:25 +01:00
коммит произвёл GitHub
родитель 5dcd37d7e3
Коммит 3dbb0201a4
2 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@@ -85,13 +85,13 @@ func UpdateAssetsSubpath(subpath string) error {
newRootHtml := string(oldRootHtml)
reCSP := regexp.MustCompile(`<meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.segment.com/analytics.js/([^"]*)">`)
reCSP := regexp.MustCompile(`<meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.segment.com/analytics.js/ cdn.rudderlabs.com/([^"]*)">`)
if results := reCSP.FindAllString(newRootHtml, -1); len(results) == 0 {
return fmt.Errorf("failed to find 'Content-Security-Policy' meta tag to rewrite")
}
newRootHtml = reCSP.ReplaceAllLiteralString(newRootHtml, fmt.Sprintf(
`<meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.segment.com/analytics.js/%s">`,
`<meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.segment.com/analytics.js/ cdn.rudderlabs.com/%s">`,
GetSubpathScriptHash(subpath),
))