This commit is contained in:
Brian Smith 2024-01-03 15:34:22 -06:00 committed by roytam1
commit bfabbcd311
3 changed files with 12 additions and 0 deletions

View file

@ -1115,6 +1115,10 @@ nsCSPParser::directive()
return;
}
if (CSP_IsEmptyDirective(mCurValue, mCurToken)) {
return;
}
// Try to create a new CSPDirective
nsCSPDirective* cspDir = directiveName();
if (!cspDir) {

View file

@ -292,6 +292,13 @@ CSP_CreateHostSrcFromSelfURI(nsIURI* aSelfURI)
return hostsrc;
}
bool
CSP_IsEmptyDirective(const nsAString& aValue, const nsAString& aDir)
{
return (aDir.Length() == 0 &&
aValue.Length() == 0);
}
bool
CSP_IsValidDirective(const nsAString& aDir)
{

View file

@ -235,6 +235,7 @@ nsresult CSP_AppendCSPFromHeader(nsIContentSecurityPolicy* aCsp,
class nsCSPHostSrc;
nsCSPHostSrc* CSP_CreateHostSrcFromSelfURI(nsIURI* aSelfURI);
bool CSP_IsEmptyDirective(const nsAString& aValue, const nsAString& aDir);
bool CSP_IsValidDirective(const nsAString& aDir);
bool CSP_IsDirective(const nsAString& aValue, CSPDirective aDir);
bool CSP_IsKeyword(const nsAString& aValue, enum CSPKeyword aKey);