Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Adjust variable filename, prevent case sensitive config PHP error.
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasmiguel authored and bsweeney committed Sep 25, 2015
1 parent 350c681 commit be53f58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions lib/Cpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3504,7 +3504,7 @@ function stream($options = '')

//FIXME: I don't know that this is sufficient for determining content length (i.e. what about transport compression?)
header("Content-Length: " . mb_strlen($tmp, '8bit'));
$fileName = (isset($options['Content-Disposition']) ? $options['Content-Disposition'] : 'document.pdf');
$filename = (isset($options['Content-Disposition']) ? $options['Content-Disposition'] : 'document.pdf');
$filename = str_replace(array("\n", "'"), "", basename($filename)) . '.pdf';

if (!isset($options["Attachment"])) {
Expand All @@ -3514,10 +3514,10 @@ function stream($options = '')
$attachment = $options["Attachment"] ? "attachment" : "inline";

// detect the character encoding of the incoming file
$encoding = mb_detect_encoding($fileName);
$fallbackfilename = mb_convert_encoding($fileName, "ISO-8859-1", $encoding);
$encoding = mb_detect_encoding($filename);
$fallbackfilename = mb_convert_encoding($filename, "ISO-8859-1", $encoding);
$encodedfallbackfilename = rawurlencode($fallbackfilename);
$encodedfilename = rawurlencode($fileName);
$encodedfilename = rawurlencode($filename);

header(
"Content-Disposition: $attachment; filename=" . $encodedfallbackfilename . "; filename*=UTF-8''$encodedfilename"
Expand Down Expand Up @@ -3883,11 +3883,11 @@ function addText($x, $y, $size, $text, $angle = 0, $wordSpaceAdjust = 0, $charSp
if ($wordSpaceAdjust != 0) {
$this->addContent(sprintf(" %.3F Tw", 0));
}

if ($charSpaceAdjust != 0) {
$this->addContent(sprintf(" %.3F Tc", 0));
}

$this->addContent(' ET');

// if there are any open callbacks, then they should be called, to show the end of the line
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/GD.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,10 @@ function stream($filename, $options = null)
$attach = (isset($options["Attachment"]) && $options["Attachment"]) ? "attachment" : "inline";

// detect the character encoding of the incoming file
$encoding = mb_detect_encoding($fileName);
$fallbackfilename = mb_convert_encoding($fileName, "ISO-8859-1", $encoding);
$encoding = mb_detect_encoding($filename);
$fallbackfilename = mb_convert_encoding($filename, "ISO-8859-1", $encoding);
$encodedfallbackfilename = rawurlencode($fallbackfilename);
$encodedfilename = rawurlencode($fileName);
$encodedfilename = rawurlencode($filename);

header("Content-Disposition: $attach; filename=". $encodedfallbackfilename ."; filename*=UTF-8''$encodedfilename");

Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/PDFLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1093,10 +1093,10 @@ function stream($filename, $options = null)
$attach = (isset($options["Attachment"]) && $options["Attachment"]) ? "attachment" : "inline";

// detect the character encoding of the incoming file
$encoding = mb_detect_encoding($fileName);
$fallbackfilename = mb_convert_encoding($fileName, "ISO-8859-1", $encoding);
$encoding = mb_detect_encoding($filename);
$fallbackfilename = mb_convert_encoding($filename, "ISO-8859-1", $encoding);
$encodedfallbackfilename = rawurlencode($fallbackfilename);
$encodedfilename = rawurlencode($fileName);
$encodedfilename = rawurlencode($filename);

header("Content-Disposition: $attach; filename=". $encodedfallbackfilename ."; filename*=UTF-8''$encodedfilename");

Expand Down

0 comments on commit be53f58

Please sign in to comment.