I am putting a unique string of text onto a PDF document using PDF::API2. Here is the minimal code to demonstrate:

#!/usr/bin/perl -T use CGI::Carp qw(fatalsToBrowser); use FindBin qw($RealBin); my $safepath; BEGIN { if ($RealBin =~ m!^(/home/...path.to.site.../(test|uk)/www)!) { $safepath = "$1/../lib"; } else { die "Insecure access!"; } } use lib "$safepath"; use cPanelUserConfig; use PDF::API2; use strict; use warnings; my $pdf = PDF::API2->open("$ENV{'DOCUMENT_ROOT'}/../data/xmas/GiftSub +scription.pdf"); my $font = $pdf->font("$ENV{'DOCUMENT_ROOT'}/../data/xmas/Merriweather +.ttf"); my $page = $pdf->open_page(1); my $text = $page->text; $text->font($font, 36); $text->position(656, 403); $text->text('ABC-123'); $pdf->save("$ENV{'DOCUMENT_ROOT'}/test.pdf"); print "Content-type: text/plain\n\n"; print "$ENV{'HTTP_HOST'}/test.pdf\n";
This works as expected when taint mode is off. But, once taint mode is turned on I get:
Insecure dependency in open while running with -T switch at /usr/lib64 +/perl5/IO/File.pm line 187

I have replaced $ENV{'DOCUMENT_ROOT'} with hardcoded paths to ensure that it is not this that is causing the problem.

Is it possible to use PDF::API2 in taint mode or do I have to choose between finding another module or turning off taint mode?


In reply to Insecure Dependency in Taint Mode by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.