Subject: | Fail with decoded paths |
Date: | Mon, 28 Jul 2014 16:14:21 +0200 |
To: | bug-CAM-PDF [...] rt.cpan.org |
From: | Marco Pessotto <melmothx [...] gmail.com> |
Hello there and thanks for CAM::PDF.
It looks like passing a decoded string to the CAM::PDF constructor, the
module can't handle the stream, because the decoding is inherited into
the stream. I hit this bug on perl 5.20, but not in perl 5.14.
For what is worth, the test.pdf is a PDF version 1.5, attached.
Best wishes
#!/usr/bin/env perl
use utf8;
use strict;
use warnings;
use Test::More tests => 7;
use File::Spec;
use CAM::PDF;
use Encode qw/encode_utf8 decode_utf8 is_utf8/;
my $enc_filename = File::Spec->rel2abs("test.pdf");
my $dec_filename = decode_utf8(File::Spec->rel2abs("test.pdf"));
ok(is_utf8($dec_filename), "dec is decoded");
ok(!is_utf8($enc_filename), "enc is encoded");
is ($enc_filename, $dec_filename, "repo paths match");
ok(-e $enc_filename);
ok(-e $dec_filename);
ok (CAM::PDF->new($enc_filename), "encoded path works")
or diag $CAM::PDF::errstr;
ok (CAM::PDF->new($dec_filename), "decoded path fails")
or diag $CAM::PDF::errstr;
__END__
1..7
ok 1 - dec is decoded
ok 2 - enc is encoded
ok 3 - repo paths match
ok 4
ok 5
ok 6 - encoded path works
not ok 7 - decoded path fails
# Failed test 'decoded path fails'
# at cam-pdf.pl line 27.
# Invalid xref stream: could not decode the stream
# Looks like you failed 1 test of 7.
Message body not shown because it is not plain text.
--
Marco