Bug 21122: Fix check-url-quick when utf8 characters in URL's
authorLiz Rea <liz@catalyst.net.nz>
Thu, 26 Jul 2018 04:26:15 +0000 (16:26 +1200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 2 Aug 2018 13:21:43 +0000 (10:21 -0300)
To test:

Make a record with a URL that has a UTF8 character, such as:
http://some.nonexistent.tld/MāoriWomenAotearoa.pdf
Run the check-url-quick.pl job, notice it dies at that URL
Apply this patch
Test again, it should work.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

misc/cronjobs/check-url-quick.pl

index f9b1c32..22d2dfe 100755 (executable)
@@ -24,6 +24,7 @@ use C4::Context;
 use C4::Biblio;
 use AnyEvent;
 use AnyEvent::HTTP;
+use Encode;
 
 my ( $verbose, $help, $html ) = ( 0, 0, 0 );
 my ( $host,    $host_intranet ) = ( '', '' );
@@ -96,6 +97,7 @@ sub check_all_url {
                         my $url = $field->subfield('u');
                         next unless $url;
                         $url = "$host/$url" unless $url =~ /^http/i;
+                        $url = encode_utf8($url);
                         $count++;
                         http_request(
                             HEAD    => $url,