package main import ( "crypto/sha256" "encoding/base64" "regexp" "strings" ) var ( scriptElement = regexp.MustCompile(`(?is)]*)>(.*?)`) scriptSrcAttribute = regexp.MustCompile(`(?i)\bsrc\s*=`) // A browser reads a CR or CRLF in the HTML source as LF, and hashes that. htmlNewlines = strings.NewReplacer("\r\n", "\n", "\r", "\n") ) // inlineScriptHashes returns a CSP hash source for every inline