Subject: | abs2rel problem with unicode paths |
Using Perl version 5.20.1 on a Linux laptop. When running the following script:
use feature qw(say);
use strict;
use utf8;
use warnings;
use Env qw(HOME);
use File::Spec::Functions qw(abs2rel);
my $tdir = 'ø';
my $path = "$HOME/$tdir/b/æ";
my $base = "$HOME/$tdir";
chdir $base;
binmode STDOUT, ":utf8";
say abs2rel( $path, $base );
say abs2rel( $path );
I get output:
b/æ
../ø/b/æ
Expected output:
b/æ
../ø/b/æ
Assumed problem:
Line 409 in Unix.pm
( https://metacpan.org/source/SMUELLER/PathTools-3.47/lib/File/Spec/Unix.pm )
$base = $self->_cwd() unless defined $base and length $base;
calls Cwd::getcwd() which returns bytes, this causes $base not to be recognized as a prefix for $path..
Fix: _cwd() should return unicode in this case.