Skip to content

Commit ba5345f

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

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

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)