handle empty query parameters
[catagits/Web-Simple.git] / lib / Web / Dispatch / ParamParser.pm
index 0f403aa..e55c312 100644 (file)
@@ -27,7 +27,8 @@ sub get_unpacked_body_from {
       _unpack_params($buf);
     } elsif (index($ct, 'multipart/form-data') >= 0) {
       my $p = get_unpacked_body_object_from($_[0])->param;
-      # forcible arrayification
+      # forcible arrayification (functional, $p does not belong to us,
+      # do NOT replace this with a side-effect ridden "simpler" version)
       +{
         map +(ref($p->{$_}) eq 'ARRAY'
                ? ($_ => $p->{$_})
@@ -103,7 +104,7 @@ sub get_unpacked_uploads_from {
     (my $params = $_[0]) =~ s/\+/ /g;
     my ($name, $value);
     foreach my $pair (split(/[&;](?:\s+)?/, $params)) {
-      next unless (($name, $value) = split(/=/, $pair, 2)) == 2;
+      $value = 1 unless (($name, $value) = split(/=/, $pair, 2)) == 2;
 
       s/$DECODE/$hex_chr{$1}/gs for ($name, $value);
       $_ = decode_utf8 $_ for ($name, $value);