Skip to content

Commit 7f78801

Browse files
author
Fernando Corrêa de Oliveira
committed
Fix throwing with client-supplied invalid cookie (copy of croservices#126 vrurg++)
1 parent 0c30cd6 commit 7f78801

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

lib/Cro/HTTP/Request.rakumod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ class Cro::HTTP::Request does Cro::HTTP::Message {
167167
!! @str[0].value.split(/';' ' '?/).List;
168168
my @res;
169169
for @str {
170+
CATCH {
171+
when X::TypeCheck::Assignment {
172+
# Skip cookies with invalid name or value.
173+
# Since they're received from a client we must not die.
174+
# But neither we're obliged to maintain them.
175+
.rethrow unless .symbol eq '$!value' | '$!name';
176+
next
177+
}
178+
}
170179
my ($name, $value) = $_.split('=');
171180
@res.push: Cro::HTTP::Cookie.new(:$name, :$value) if $name;
172181
}

0 commit comments

Comments
 (0)