github / secure_headers

Manages application of security headers with many safe defaults
MIT License
3.16k stars 252 forks source link

normalize domains with trailing slashes #477

Open keithamus opened 2 years ago

keithamus commented 2 years ago

All PRs:

Adding a new header

Generally, adding a new header is always OK.

Adding a new CSP directive


This PR normalises CSP source expressions to exclude trailing slashes from the Domain if there is no other information in the path.

CSP3 more explicitly calls this out in the path match algorithm:

If path A consists of one character that is equal to the U+002F SOLIDUS character (/) and path B is empty, return "Matches".

Also a URL like example.com/foo will match a source expression of example.com, as well as example.com/, so having two source expressions listed like this is redundant.

srt32 commented 2 years ago

@keithamus @vcsjones anything I can do to help get this PR ready to ship?