Skip to content

Commit fffe951

Browse files
committed
fix: trim whitespace in origin allowlist entries
DOWS_ALLOWED_ORIGINS now trims each comma-separated entry (and the Origin header value) before matching, matching DOWS_ALLOWED_UPSTREAMS.
1 parent 83be85c commit fffe951

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,9 @@ async fn handle_connection(mut sock: TcpStream, policy: Arc<Policy>) -> io::Resu
9898

9999
for h in request.headers.iter() {
100100
if h.name.eq_ignore_ascii_case("origin") {
101-
if policy
102-
.allowed_origins
103-
.as_ref()
104-
.is_some_and(|x| !x.split(",").any(|x| x.as_bytes() == h.value))
105-
{
101+
if policy.allowed_origins.as_ref().is_some_and(|x| {
102+
!x.split(",").map(str::trim).any(|x| x.as_bytes() == h.value.trim_ascii())
103+
}) {
106104
let resp = "HTTP/1.1 403 Forbidden\r\n\
107105
Connection: close\r\n\
108106
Content-Type: text/plain\r\n\r\n";

0 commit comments

Comments
 (0)