Skip Menu |

This queue is for tickets about the CAM-PDF CPAN distribution.

Report information
The Basics
Id: 120952
Status: new
Priority: 0/
Queue: CAM-PDF

People
Owner: Nobody in particular
Requestors: futuramedium [...] yandex.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.60
Fixed in: (no value)



Subject: Constructor parameter (file name) should not be re-used 'as is' to receive file content
use strict; use warnings; use CAM::PDF; my $utf8_name = "\x{03C0}.pdf"; system("cp pdf15.pdf $utf8_name"); CAM::PDF-> new( $utf8_name ) or die $CAM::PDF::errstr; The 'pdf15.pdf' is part of test suite and known to be valid. File content is read into same scalar, which was passed to constructor as filename. If filename happens to be utf8, then content string remains utf8, not byte string (regardless of binmode performed on filehandle). PDF streams are inflated (through Text::PDF) using OO-interface of Compress::Zlib. Which doesn't like utf8 strings: use strict; use warnings; use feature 'say'; use utf8; use Compress::Zlib; my $x = my $y = compress( 'foo' ); utf8::upgrade( $x ); utf8::upgrade( $y ); my $i = Compress::Zlib::inflateInit(); say uncompress( $x ); say for $i-> inflate( $y ); "$content = undef;" after line 313 in PDF.pm will fix it.
From: futuramedium [...] yandex.ru
That's re: 120773, 120793. On Wed Apr 05 06:48:09 2017, vadimr wrote: Show quoted text
> use strict; > use warnings; > use CAM::PDF; > > my $utf8_name = "\x{03C0}.pdf"; > system("cp pdf15.pdf $utf8_name"); > > CAM::PDF-> new( $utf8_name ) > or die $CAM::PDF::errstr; > > The 'pdf15.pdf' is part of test suite and known to be valid. File > content is read into same scalar, which was passed to constructor as > filename. If filename happens to be utf8, then content string remains > utf8, not byte string (regardless of binmode performed on filehandle). > PDF streams are inflated (through Text::PDF) using OO-interface of > Compress::Zlib. Which doesn't like utf8 strings: > > use strict; > use warnings; > use feature 'say'; > use utf8; > use Compress::Zlib; > > my $x = my $y = compress( 'foo' ); > utf8::upgrade( $x ); > utf8::upgrade( $y ); > my $i = Compress::Zlib::inflateInit(); > > say uncompress( $x ); > say for $i-> inflate( $y ); > > "$content = undef;" after line 313 in PDF.pm will fix it.