diff --git a/FU/Util.pm b/FU/Util.pm index 5b262fb..7d585d9 100644 --- a/FU/Util.pm +++ b/FU/Util.pm @@ -41,6 +41,7 @@ sub uri_unescape :prototype($) ($s) { sub query_decode :prototype($) ($s) { my %o; for (split /&/, $s//'') { + next if !length; my($k,$v) = map uri_unescape($_), split /=/, $_, 2; $v //= builtin::true; if (ref $o{$k}) { push $o{$k}->@*, $v } diff --git a/t/query.t b/t/query.t index ebeff80..80f2b00 100644 --- a/t/query.t +++ b/t/query.t @@ -10,6 +10,8 @@ is_deeply ok !eval { query_decode('%10'); 1 }; like $@, qr/Invalid control character/; +is_deeply query_decode('&&&a=b'), { a => 'b' }; + is query_encode { a => builtin::true, b => undef, c => builtin::false, d => 'string', e => "&=\xfe" }, 'a&d=string&e=%26%3d%c3%be';