]> git.sesse.net Git - webpdf/blobdiff - createpdf.pl
Upgraded ImageMagick on cirkus, so no problems with PDF output from ImageMagick anymore.
[webpdf] / createpdf.pl
index 86187fba167590e27420cb3930d6e115c28451ea..8bece1ce8182857e30952eb6a617c8186c5a3cc6 100755 (executable)
@@ -70,7 +70,7 @@ if ($filename =~ /(.*)\.(?:e?ps|pdf)$/i) {
        $outname = "$1.pdf";
 
        # Run through ImageMagick first of all, then gs
-       open PIPE, "| convert $2:- ps:- | gs $pdfopts -dCompatbilityLevel=1.4 -dNOPAUSE -dPATCH -sDEVICE=pdfwrite -dSAFER -sOutputFile=output/$pdf_filename -c '.setpdfwrite $psopts' -f - >&2"
+       open PIPE, "| convert $2:- pdf:- | gs $pdfopts -dCompatbilityLevel=1.4 -dNOPAUSE -dPATCH -sDEVICE=pdfwrite -dSAFER -sOutputFile=output/$pdf_filename -c '.setpdfwrite $psopts' -f - >&2"
                 or die "convert: $!";
 
        my ($buf, $ret);
@@ -139,8 +139,10 @@ EOF
 
 my $size = -s "output/$pdf_filename";
 
+(my $sanitized_outname = $outname) =~ tr/a-zA-Z0-9. -/_/c;
+
 print "Content-type: application/pdf\n";
-print "Content-disposition: attachment; filename=\"$outname\"\n";  # FIXME: XSS problems?
+print "Content-disposition: attachment; filename=\"$sanitized_outname\"\n";
 print "Content-length: $size\n\n";
 
 system("cat output/$pdf_filename");  # yuck?