Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CspParser wrongly split directive using data: source containing ;base64... #65

Open
Pamplemousse opened this issue Feb 5, 2024 · 0 comments

Comments

@Pamplemousse
Copy link

"data" URL schemes can contain a ; when using the base64 extension.
When such scheme is used as a directive source, it seems that this ; trips the current CspParser, which wrongly splits the directive, as shown in the example below:

import { CspParser } from "csp_evaluator/dist/parser.js";

const example = "script-src 'nonce-xyz' data:image/png;base64,SGVsbG8sIFdvcmxkIQ== 'strict-dynamic'";
const { csp } = new CspParser(example);

console.log(csp)
Csp {
  directives: {
    'script-src': [ "'nonce-xyz'", 'data:image/png' ],
    'base64,sgvsbg8sifdvcmxkiq==': [ "'strict-dynamic'" ]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant