Commit 95a938d
authored
normalize domains with trailing slashes (#477)
## All PRs:
* [x] Has tests
* [ ] Documentation updated - N/A
## Adding a new header
Generally, adding a new header is always OK.
* Is the header supported by any user agent? If so, which?
* What does it do?
* What are the valid values for the header?
* Where does the specification live?
## Adding a new CSP directive
* Is the directive supported by any user agent? If so, which?
* What does it do?
* What are the valid values for the 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](https://www.w3.org/TR/CSP/#path-part-match):
> 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.File tree
2 files changed
+31
-2
lines changed- lib/secure_headers/headers
- spec/lib/secure_headers/headers
2 files changed
+31
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
154 | 175 | | |
155 | 176 | | |
156 | 177 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | | - | |
| 61 | + | |
54 | 62 | | |
55 | 63 | | |
56 | | - | |
| 64 | + | |
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
| |||
0 commit comments