Skip to content

Commit 58d8e4d

Browse files
authored
Merge pull request #210 from FCO/copy-of-fix-bad-client-cookie
Fix throwing with client-supplied invalid cookie (copy of #126 vrurg++)
2 parents 0c30cd6 + ba5345f commit 58d8e4d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Revision history for Cro::HTTP
44
- Support link generation
55
- Make http function accept a list of http methods
66
- Catch URI parse errors during routing
7+
- Fix throwing with client-supplied invalid cookie
78

89
0.8.11
910
- Avoid sending a 0-byte WINDOW_UPDATE frame.

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)