diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-06-14 10:38:37 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-06-14 10:38:37 +0100 |
commit | afca06d29ca7c5597d6570095b4b352dcc12b9f9 (patch) | |
tree | 35c2b3f258809263d31c38994254d59e969853ef /perllib/Open311.pm | |
parent | d9f2c5e76590d56e30a7e5fbaaa388e4addc46a3 (diff) | |
parent | ad293e8de86d9911f7031fdd996d235f590c0d15 (diff) |
Merge branch 'open311-encode-for-uploads'
Diffstat (limited to 'perllib/Open311.pm')
-rw-r--r-- | perllib/Open311.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/perllib/Open311.pm b/perllib/Open311.pm index a902a7213..ebf3ee987 100644 --- a/perllib/Open311.pm +++ b/perllib/Open311.pm @@ -8,6 +8,7 @@ use XML::Simple; use LWP::Simple; use LWP::UserAgent; use DateTime::Format::W3CDTF; +use Encode; use HTTP::Request::Common qw(GET POST); use FixMyStreet::Cobrand; use FixMyStreet::DB; @@ -495,11 +496,19 @@ sub _request { my $debug_request = $method . ' ' . $uri->as_string . "\n\n"; my $req = do { + $params = { + map { + my $value = $params->{$_}; + $_ => ref $value eq 'ARRAY' + ? [ map { encode('UTF-8', $_) } @$value ] + : encode('UTF-8', $value) + } keys %$params + }; if ($method eq 'GET') { $uri->query_form( $params ); GET $uri->as_string; } elsif ($method eq 'POST') { - if ($uploads) { + if ($uploads && %$uploads) { # HTTP::Request::Common needs to be constructed slightly # differently if there are files to upload. |