1 # This module is part of debbugs, and is released
2 # under the terms of the GPL version 2, or any later
3 # version at your option.
4 # See the file README and COPYING for more information.
6 # Copyright 2007 by Don Armstrong <don@donarmstrong.com>.
8 # Copyright 1995-2003 Gisle Aas.
9 # Copyright 1995 Martijn Koster.
16 Debbugs::URI -- Derivative of URI which overrides the query_param
17 method to use ';' instead of '&' for separators.
25 See L<URI> for more information.
35 use base qw(URI URI::_query);
39 $uri->query_form( $key1 => $val1, $key2 => $val2, ... )
41 Exactly like query_param in L<URI> except query elements are joined by
50 no warnings 'redefine';
51 # Handle ...?foo=bar&bar=foo type of query
52 sub URI::_query::query_form {
54 my $old = $self->query;
56 # Try to set query string
60 if (ref($n) eq "ARRAY") {
63 elsif (ref($n) eq "HASH") {
68 while (my($key,$vals) = splice(@new, 0, 2)) {
69 $key = '' unless defined $key;
70 $key =~ s/([;\/?:@&=+,\$\[\]%])/$URI::Escape::escapes{$1}/g;
72 $vals = [ref($vals) eq "ARRAY" ? @$vals : $vals];
73 for my $val (@$vals) {
74 $val = '' unless defined $val;
75 $val =~ s/([;\/?:@&=+,\$\[\]%])/$URI::Escape::escapes{$1}/g;
77 push(@query, "$key=$val");
80 # We've changed & to a ; here.
81 $self->query(@query ? join(';', @query) : undef);
83 return if !defined($old) || !length($old) || !defined(wantarray);
84 return unless $old =~ /=/; # not a form
85 map { s/\+/ /g; uri_unescape($_) }
86 # We've also changed the split here to split on ; as well as &
87 map { /=/ ? split(/=/, $_, 2) : ($_ => '')} split(/[&;]/, $old);