vendor: Update dompdf to a fixed version for PHP 7.3

https://github.com/dompdf/dompdf/pull/1854
This commit is contained in:
Markus Frosch 2018-12-05 13:31:06 +01:00
parent ecfaf7cede
commit f4f61dff5b
12 changed files with 93 additions and 31 deletions

View File

@ -1,16 +1,26 @@
GLOBIGNORE=$0; rm -rf *
#!/bin/bash
set -eux
#GLOBIGNORE=$0; rm -rf *
curl https://codeload.github.com/dompdf/dompdf/tar.gz/v0.8.2 -o dompdf-0.8.2.tar.gz
tar xzf dompdf-0.8.2.tar.gz --strip-components 1 dompdf-0.8.2/{lib,src,LICENSE.LGPL}
rm dompdf-0.8.2.tar.gz
#DOMPDF_VERSION=0.8.2
DOMPDF_VERSION=6a77a427984f97743018ace3e095fbf0edaaee29 # https://github.com/dompdf/dompdf/pull/1854
PHP_FONTLIB_VERSION=0.5.1
PHP_SVGLIB_VERSION=0.3.2
rm -rf lib/ src/
curl -LsS https://github.com/dompdf/dompdf/archive/"$DOMPDF_VERSION".tar.gz -o /tmp/dompdf.tar.gz
tar xf /tmp/dompdf.tar.gz --strip-components 1 dompdf-"$DOMPDF_VERSION"/{lib,src,LICENSE.LGPL}
rm /tmp/dompdf.tar.gz
mv LICENSE.LGPL LICENSE
curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.5.1 -o php-font-lib-0.5.1.tar.gz
mkdir -p lib/php-font-lib
tar xzf php-font-lib-0.5.1.tar.gz --strip-components 1 -C lib/php-font-lib php-font-lib-0.5.1/{src,LICENSE}
rm php-font-lib-0.5.1.tar.gz
curl -LsS https://github.com/PhenX/php-font-lib/archive/"$PHP_FONTLIB_VERSION".tar.gz -o /tmp/php-font-lib.tar.gz
[ -d lib/php-font-lib ] || mkdir -p lib/php-font-lib
tar xf /tmp/php-font-lib.tar.gz --strip-components 1 -C lib/php-font-lib php-font-lib-"$PHP_FONTLIB_VERSION"/{src,LICENSE}
rm /tmp/php-font-lib.tar.gz
curl https://codeload.github.com/PhenX/php-svg-lib/tar.gz/v0.3.2 -o php-svg-lib-0.3.2.tar.gz
mkdir -p lib/php-svg-lib
tar xzf php-svg-lib-0.3.2.tar.gz --strip-components 1 -C lib/php-svg-lib php-svg-lib-0.3.2/src
rm php-svg-lib-0.3.2.tar.gz
curl -LsS https://github.com/PhenX/php-svg-lib/archive/v"$PHP_SVGLIB_VERSION".tar.gz -o /tmp/php-svg-lib.tar.gz
[ -d lib/php-svg-lib ] || mkdir -p lib/php-svg-lib
tar xf /tmp/php-svg-lib.tar.gz --strip-components 1 -C lib/php-svg-lib php-svg-lib-"$PHP_SVGLIB_VERSION"/src
rm /tmp/php-svg-lib.tar.gz

View File

@ -464,28 +464,28 @@ class Cpdf
// Named with limited valid values
case 'NonFullScreenPageMode':
if (!in_array($v, array('UseNone', 'UseOutlines', 'UseThumbs', 'UseOC'))) {
continue;
continue 2;
}
$o['info'][$k] = $v;
break;
case 'Direction':
if (!in_array($v, array('L2R', 'R2L'))) {
continue;
continue 2;
}
$o['info'][$k] = $v;
break;
case 'PrintScaling':
if (!in_array($v, array('None', 'AppDefault'))) {
continue;
continue 2;
}
$o['info'][$k] = $v;
break;
case 'Duplex':
if (!in_array($v, array('None', 'AppDefault'))) {
continue;
continue 2;
}
$o['info'][$k] = $v;
break;
@ -4801,12 +4801,12 @@ EOT;
imagesavealpha($img, false);
// create temp alpha file
$tempfile_alpha = tempnam($this->tmp, "cpdf_img_");
$tempfile_alpha = @tempnam($this->tmp, "cpdf_img_");
@unlink($tempfile_alpha);
$tempfile_alpha = "$tempfile_alpha.png";
// create temp plain file
$tempfile_plain = tempnam($this->tmp, "cpdf_img_");
$tempfile_plain = @tempnam($this->tmp, "cpdf_img_");
@unlink($tempfile_plain);
$tempfile_plain = "$tempfile_plain.png";

View File

@ -561,6 +561,25 @@ class CPDF implements Canvas
$this->_set_line_transparency("Normal", $this->_current_opacity);
}
/**
* Draw line at the specified coordinates on every page.
*
* See {@link Style::munge_color()} for the format of the colour array.
*
* @param float $x1
* @param float $y1
* @param float $x2
* @param float $y2
* @param array $color
* @param float $width
* @param array $style optional
*/
public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = array())
{
$_t = 'line';
$this->_page_text[] = compact('_t', 'x1', 'y1', 'x2', 'y2', 'color', 'width', 'style');
}
/**
* @param float $x
* @param float $y
@ -608,7 +627,7 @@ class CPDF implements Canvas
imageinterlace($im, false);
$tmp_dir = $this->_dompdf->getOptions()->getTempDir();
$tmp_name = tempnam($tmp_dir, "{$type}dompdf_img_");
$tmp_name = @tempnam($tmp_dir, "{$type}dompdf_img_");
@unlink($tmp_name);
$filename = "$tmp_name.png";
$this->_image_cache[] = $filename;
@ -1092,6 +1111,10 @@ class CPDF implements Canvas
}
$eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
break;
case 'line':
$this->line( $x1, $y1, $x2, $y2, $color, $width, $style );
break;
}
}

View File

@ -729,7 +729,7 @@ class GD implements Canvas
$func_name = "imagecreatefrom$img_type";
if (!function_exists($func_name)) {
if (!method_exists("Dompdf\Helpers", $func_name)) {
throw new \Exception("Function $func_name() not found. Cannot convert $type image: $img_url. Please install the image PHP extension.");
throw new \Exception("Function $func_name() not found. Cannot convert $img_type image: $img_url. Please install the image PHP extension.");
}
$func_name = "\\Dompdf\\Helpers::" . $func_name;
}
@ -978,6 +978,11 @@ class GD implements Canvas
// N/A
}
public function page_line()
{
// N/A
}
/**
* Streams the image to the client.
*

View File

@ -208,7 +208,7 @@ class PDFLib implements Canvas
$this->_pdf->begin_document("", "");
} else {
$tmp_dir = $this->_dompdf->getOptions()->getTempDir();
$tmp_name = tempnam($tmp_dir, "libdompdf_pdf_");
$tmp_name = @tempnam($tmp_dir, "libdompdf_pdf_");
@unlink($tmp_name);
$this->_file = "$tmp_name.pdf";
$this->_pdf->begin_document($this->_file, "");
@ -762,6 +762,25 @@ class PDFLib implements Canvas
$this->_set_line_transparency("Normal", $this->_current_opacity);
}
/**
* Draw line at the specified coordinates on every page.
*
* See {@link Style::munge_color()} for the format of the colour array.
*
* @param float $x1
* @param float $y1
* @param float $x2
* @param float $y2
* @param array $color
* @param float $width
* @param array $style optional
*/
public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = array())
{
$_t = 'line';
$this->_page_text[] = compact('_t', 'x1', 'y1', 'x2', 'y2', 'color', 'width', 'style');
}
/**
* @param float $x1
* @param float $y1
@ -1259,6 +1278,11 @@ class PDFLib implements Canvas
}
$eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
break;
case 'line':
$this->line( $x1, $y1, $x2, $y2, $color, $width, $style );
break;
}
}

View File

@ -1357,7 +1357,7 @@ class Stylesheet
$key = $page_selector;
default:
continue;
continue 3;
}
// Store the style for later...

View File

@ -368,7 +368,7 @@ class Dompdf
$ext = strtolower(pathinfo($realfile, PATHINFO_EXTENSION));
if (!in_array($ext, $this->allowedLocalFileExtensions)) {
throw new Exception("Permission denied on $file.");
throw new Exception("Permission denied on $file. This file extension is forbidden");
}
if (!$realfile) {
@ -607,7 +607,7 @@ class Dompdf
if (!$accept) {
//found at least one mediatype, but none of the accepted ones
//Skip this css file.
continue;
continue 2;
}
}
@ -628,7 +628,7 @@ class Dompdf
($media = $tag->getAttribute("media")) &&
!in_array($media, $acceptedmedia)
) {
continue;
continue 2;
}
$css = "";
@ -945,7 +945,7 @@ class Dompdf
*
* @param array $options options (see above)
*
* @return string
* @return string|null
*/
public function output($options = array())
{

View File

@ -186,7 +186,7 @@ class FontMetrics
$fontDir = $this->getOptions()->getFontDir();
$remoteHash = md5($remoteFile);
$localFile = $fontDir . DIRECTORY_SEPARATOR . $remoteHash;
$localTempFile = tempnam($this->options->get("tempDir"), "dompdf-font-");
$localTempFile = @tempnam($this->options->get("tempDir"), "dompdf-font-");
$cacheEntry = $localFile;
$localFile .= ".".strtolower(pathinfo(parse_url($remoteFile, PHP_URL_PATH),PATHINFO_EXTENSION));

View File

@ -515,7 +515,7 @@ class Page extends AbstractFrameDecorator
// parents of $frame must fit on the page as well:
$p = $frame->get_parent();
while ($p) {
$max_y += $p->get_style()->computed_bottom_spacing();
$max_y += (float) $p->get_style()->computed_bottom_spacing();
$p = $p->get_parent();
}

View File

@ -88,7 +88,7 @@ class Cache
} // From remote
else {
$tmp_dir = $dompdf->getOptions()->getTempDir();
$resolved_url = tempnam($tmp_dir, "ca_dompdf_img_");
$resolved_url = @tempnam($tmp_dir, "ca_dompdf_img_");
$image = "";
if ($data_uri) {

View File

@ -401,7 +401,7 @@ abstract class AbstractRenderer
$this->_canvas->get_cpdf()->addImagePng($filedummy, $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg);
} else {
$tmp_dir = $this->_dompdf->getOptions()->getTempDir();
$tmp_name = tempnam($tmp_dir, "bg_dompdf_img_");
$tmp_name = @tempnam($tmp_dir, "bg_dompdf_img_");
@unlink($tmp_name);
$tmp_file = "$tmp_name.png";

View File

@ -137,7 +137,7 @@ class Text extends AbstractRenderer
switch ($text_deco) {
default:
continue;
continue 2;
case "underline":
$deco_y += $base - $descent + $underline_offset + $line_thickness / 2;