MDL-76910 libraries: upgrade to version 6.6.2 of TCPDF.

This commit is contained in:
Paul Holden 2023-03-02 11:31:02 +00:00
parent 9ee4f8db8b
commit 6e4f1b9a5e
9 changed files with 82 additions and 87 deletions

View File

@ -1,3 +1,24 @@
6.6.2 (2022-12-17)
- Ensure pregSplit return type is always array.
- Add ability to run tests on various operating systems (#566)
- Avoid a deprecated error from PHP8.1 (#573)
6.6.1 (2022-12-12)
- Add PHPStan and fix level 1 errors (#307)
6.6.0 (2022-12-06)
- Multi-byte character support for filename during output (#561). (#562)
- Fix garbage collection (#509)
- FIX: PDF417 corrupt output problem, solution set bcmath scale parameter to zero (#534)
- Fix TypeError: count() in PHP8 (#556)
- Fix-getHTMLFontUnits (#547)
- Improved embedded image in HTML allowing src="data:..." format (#552)
- Fix image abscissa when in RTL (#510)
- fix: php 8.1 notices (#548)
- Optimize PNG files (#563)
- Update documentation for a known issue. (#569)
- Fix for PHP 8.1 (#571)
6.5.0 (2022-08-12)
- encodeUrlQuery takes into account the port (#493)
- Fixing undefined offset error in writeHTML() when last DOM element ha…

View File

@ -12,7 +12,7 @@
"barcodes"
],
"homepage": "http://www.tcpdf.org/",
"version": "6.5.0",
"version": "6.6.2",
"license": "LGPL-3.0-only",
"authors": [
{

View File

@ -778,7 +778,7 @@ class Datamatrix {
if (isset($this->chset['SH1'][$chr])) {
$temp_cw[] = 0; // shift 1
$shiftset = $this->chset['SH1'];
} elseif (isset($chr, $this->chset['SH2'][$chr])) {
} elseif (isset($this->chset['SH2'][$chr])) {
$temp_cw[] = 1; // shift 2
$shiftset = $this->chset['SH2'];
} elseif (($enc == ENC_C40) AND isset($this->chset['S3C'][$chr])) {

View File

@ -943,8 +943,8 @@ class PDF417 {
// tmp array for the 6 bytes block
$cw6 = array();
do {
$d = bcmod($t, '900');
$t = bcdiv($t, '900');
$d = bcmod($t, '900', 0);
$t = bcdiv($t, '900', 0);
// prepend the value to the beginning of the array
array_unshift($cw6, $d);
} while ($t != '0');
@ -969,8 +969,8 @@ class PDF417 {
}
$t = '1'.$code;
do {
$d = bcmod($t, '900');
$t = bcdiv($t, '900');
$d = bcmod($t, '900', 0);
$t = bcdiv($t, '900', 0);
array_unshift($cw, $d);
} while ($t != '0');
$code = $rest;

View File

@ -1062,7 +1062,7 @@ class QRcode {
protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) {
$b = 0;
$bitMask = array();
$bitMask = $this->generateMaskNo($maskNo, $width, $s, $d);
$bitMask = $this->generateMaskNo($maskNo, $width, $s);
if ($maskGenOnly) {
return;
}
@ -1460,7 +1460,7 @@ class QRcode {
$stringLen = strlen($this->dataStr);
$p = 0;
while ($p < $stringLen) {
$mode = $this->identifyMode(substr($this->dataStr, $p), $this->hint);
$mode = $this->identifyMode(substr($this->dataStr, $p));
if ($mode == QR_MODE_KJ) {
$p += 2;
} else {
@ -1692,7 +1692,7 @@ class QRcode {
return -1;
}
$buf = array($size, $index, $parity);
$entry = $this->newInputItem(QR_MODE_ST, 3, buf);
$entry = $this->newInputItem(QR_MODE_ST, 3, $buf);
array_unshift($items, $entry);
return $items;
}

View File

@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version.
* @private static
*/
private static $tcpdf_version = '6.5.0';
private static $tcpdf_version = '6.6.2';
/**
* String alias for total number of pages.
@ -128,39 +128,6 @@ class TCPDF_STATIC {
return "\x54\x43\x50\x44\x46\x20\x28\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67\x29";
}
/**
* Sets the current active configuration setting of magic_quotes_runtime (if the set_magic_quotes_runtime function exist)
* @param boolean $mqr FALSE for off, TRUE for on.
* @since 4.6.025 (2009-08-17)
* @public static
*/
public static function set_mqr($mqr) {
if (!defined('PHP_VERSION_ID')) {
$version = PHP_VERSION;
define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
}
if (PHP_VERSION_ID < 50300) {
@set_magic_quotes_runtime($mqr);
}
}
/**
* Gets the current active configuration setting of magic_quotes_runtime (if the get_magic_quotes_runtime function exist)
* @return int Returns 0 if magic quotes runtime is off or get_magic_quotes_runtime doesn't exist, 1 otherwise.
* @since 4.6.025 (2009-08-17)
* @public static
*/
public static function get_mqr() {
if (!defined('PHP_VERSION_ID')) {
$version = PHP_VERSION;
define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
}
if (PHP_VERSION_ID < 50300) {
return @get_magic_quotes_runtime();
}
return 0;
}
/**
* Check if the URL exist.
* @param string $url URL to check.
@ -319,7 +286,7 @@ class TCPDF_STATIC {
*/
public static function _escapeXML($str) {
$replaceTable = array("\0" => '', '&' => '&amp;', '<' => '&lt;', '>' => '&gt;');
$str = strtr($str, $replaceTable);
$str = strtr($str === null ? '' : $str, $replaceTable);
return $str;
}
@ -852,9 +819,7 @@ class TCPDF_STATIC {
if (isset($prop['charLimit'])) {
$opt['maxlen'] = intval($prop['charLimit']);
}
if (!isset($ff)) {
$ff = 0; // default value
}
$ff = 0;
// readonly: The read-only characteristic of a field. If a field is read-only, the user can see the field but cannot change it.
if (isset($prop['readonly']) AND ($prop['readonly'] == 'true')) {
$ff += 1 << 0;
@ -1811,7 +1776,11 @@ class TCPDF_STATIC {
$flags = $flags === null ? 0 : $flags;
// the bug only happens on PHP 5.2 when using the u modifier
if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
return preg_split($pattern.$modifiers, $subject, $limit, $flags);
$ret = preg_split($pattern.$modifiers, $subject, $limit, $flags);
if ($ret === false) {
return array();
}
return $ret;
}
// preg_split is bugged - try alternative solution
$ret = array();
@ -2155,7 +2124,7 @@ class TCPDF_STATIC {
* Array of page formats
* measures are calculated in this way: (inches * 72) or (millimeters * 72 / 25.4)
* @public static
*
*
* @var array<string,float[]>
*/
public static $page_formats = array(

View File

@ -6,9 +6,6 @@ Description of TCPDF library import
* remove all fonts that were not already present
* visit http://127.0.0.1/lib/tests/other/pdflibtestpage.php and view the pdf
* modify getTCPDFProducer lib/tcpdf/include/tcpdf_static.php to remove the version number
* Check the status of https://github.com/tecnickcom/TCPDF/pull/548 , apply if it is still
not included or delete this entry
* modify `TCPDF::Output` method for multi-byte character filename support (see https://github.com/tecnickcom/TCPDF/pull/562)
Important
---------

View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 6.4.4
// Version : 6.6.2
// Begin : 2002-08-03
// Last Update : 2022-08-12
// Last Update : 2022-12-06
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
@ -104,7 +104,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 6.5.0
* @version 6.6.2
*/
// TCPDF configuration
@ -128,7 +128,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_static.php');
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
* @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions.
* @version 6.3.2
* @version 6.6.2
* @author Nicola Asuni - info@tecnick.com
* @IgnoreAnnotation("protected")
* @IgnoreAnnotation("public")
@ -2024,9 +2024,6 @@ class TCPDF {
$this->header_xobj_autoreset = false;
$this->custom_xmp = '';
$this->custom_xmp_rdf = '';
// Call cleanup method after script execution finishes or exit() is called.
// NOTE: This will not be executed if the process is killed with a SIGTERM or SIGKILL signal.
register_shutdown_function(array($this, '_destroy'), true);
}
/**
@ -4283,7 +4280,7 @@ class TCPDF {
// all fonts must be embedded
$family = 'pdfa'.$family;
}
$tempstyle = strtoupper($style);
$tempstyle = strtoupper($style === null ? '' : $style);
$style = '';
// underline
if (strpos($tempstyle, 'U') !== false) {
@ -4350,6 +4347,22 @@ class TCPDF {
}
// include font file
if (!TCPDF_STATIC::empty_string($fontfile) AND (@TCPDF_STATIC::file_exists($fontfile))) {
$type=null;
$name=null;
$desc=null;
$up=-null;
$ut=null;
$cw=null;
$cbbox=null;
$dw=null;
$enc=null;
$cidinfo=null;
$file=null;
$ctg=null;
$diff=null;
$originalsize=null;
$size1=null;
$size2=null;
include($fontfile);
} else {
$this->Error('Could not include font definition file: '.$family.'');
@ -5527,12 +5540,12 @@ class TCPDF {
$xdk = $xdx * $k;
// print text
$s .= sprintf('BT %F %F Td [(%s)] TJ ET', $xdk, (($this->h - $basefonty) * $k), $txt2);
if (isset($uniblock)) {
if (isset($uniblock)) { // @phpstan-ignore-line
// print overlapping characters as separate string
$xshift = 0; // horizontal shift
$ty = (($this->h - $basefonty + (0.2 * $this->FontSize)) * $k);
$spw = (($w - $txwidth - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns?$ns:1));
foreach ($uniblock as $uk => $uniarr) {
foreach ($uniblock as $uk => $uniarr) { // @phpstan-ignore-line
if (($uk % 2) == 0) {
// x space to skip
if ($spacewidth != 0) {
@ -7104,8 +7117,6 @@ class TCPDF {
} elseif ($type == 'jpg') {
$type = 'jpeg';
}
$mqr = TCPDF_STATIC::get_mqr();
TCPDF_STATIC::set_mqr(false);
// Specific image handlers (defined on TCPDF_IMAGES CLASS)
$mtd = '_parse'.$type;
// GD image handler function
@ -7207,7 +7218,6 @@ class TCPDF {
// unable to process image
return false;
}
TCPDF_STATIC::set_mqr($mqr);
if ($ismask) {
// force grayscale
$info['cs'] = 'DeviceGray';
@ -7235,7 +7245,7 @@ class TCPDF {
} elseif ($palign == 'R') {
$ximg = $this->w - $this->rMargin - $w;
} else {
$ximg = $x;
$ximg = $this->rtl ? $x - $w : $x;
}
if ($ismask OR $hidden) {
@ -8871,8 +8881,6 @@ class TCPDF {
$this->_newobj();
$this->_out('<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.'] >>'."\n".'endobj');
}
$mqr = TCPDF_STATIC::get_mqr();
TCPDF_STATIC::set_mqr(false);
foreach ($this->FontFiles as $file => $info) {
// search and get font file to embedd
$fontfile = TCPDF_FONTS::getFontFullPath($file, $info['fontdir']);
@ -8926,7 +8934,6 @@ class TCPDF {
$this->_out($out);
}
}
TCPDF_STATIC::set_mqr($mqr);
foreach ($this->fontkeys as $k) {
//Font objects
$font = $this->getFontBuffer($k);
@ -9195,6 +9202,7 @@ class TCPDF {
foreach ($this->imagekeys as $file) {
$info = $this->getImageBuffer($file);
// set object for alternate images array
$altoid = null;
if ((!$this->pdfa_mode) AND isset($info['altimgs']) AND !empty($info['altimgs'])) {
$altoid = $this->_newobj();
$out = '[';
@ -9242,7 +9250,7 @@ class TCPDF {
$out .= ' /Decode [1 0 1 0 1 0 1 0]';
}
$out .= ' /BitsPerComponent '.$info['bpc'];
if (isset($altoid) AND ($altoid > 0)) {
if ($altoid > 0) {
// reference to alternate images dictionary
$out .= ' /Alternates '.$altoid.' 0 R';
}
@ -11702,7 +11710,7 @@ class TCPDF {
if ($this->state != 2) {
return;
}
if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
if (!(false === strpos($style, 'F')) AND is_array($fill_color)) {
$this->setFillColorArray($fill_color);
}
$op = TCPDF_STATIC::getPathPaintOperator($style);
@ -11732,7 +11740,7 @@ class TCPDF {
if ($this->state != 2) {
return;
}
if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
if (!(false === strpos($style, 'F')) AND is_array($fill_color)) {
$this->setFillColorArray($fill_color);
}
$op = TCPDF_STATIC::getPathPaintOperator($style);
@ -11775,7 +11783,7 @@ class TCPDF {
if (TCPDF_STATIC::empty_string($ry) OR ($ry == 0)) {
$ry = $rx;
}
if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
if (!(false === strpos($style, 'F')) AND is_array($fill_color)) {
$this->setFillColorArray($fill_color);
}
$op = TCPDF_STATIC::getPathPaintOperator($style);
@ -11994,7 +12002,7 @@ class TCPDF {
}
$nc += 4;
}
if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
if (!(false === strpos($style, 'F')) AND is_array($fill_color)) {
$this->setFillColorArray($fill_color);
}
$op = TCPDF_STATIC::getPathPaintOperator($style);
@ -12197,7 +12205,7 @@ class TCPDF {
return;
}
// Rounded
if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
if (!(false === strpos($style, 'F')) AND is_array($fill_color)) {
$this->setFillColorArray($fill_color);
}
$op = TCPDF_STATIC::getPathPaintOperator($style);
@ -15076,9 +15084,7 @@ class TCPDF {
// translate
$this->_out(sprintf('%F %F %F %F %F %F cm', 1, 0, 0, 1, $dx, $dy + ($this->hPt - (2 * $y * $k) - ($y2 - $y1))));
// scale
if (isset($scale_x)) {
$this->_out(sprintf('%F %F %F %F %F %F cm', $scale_x, 0, 0, $scale_y, $x1 * (1 - $scale_x), $y2 * (1 - $scale_y)));
}
$this->_out(sprintf('%F %F %F %F %F %F cm', $scale_x, 0, 0, $scale_y, $x1 * (1 - $scale_x), $y2 * (1 - $scale_y)));
// handle pc/unix/mac line endings
$lines = preg_split('/[\r\n]+/si', $data, -1, PREG_SPLIT_NO_EMPTY);
$u=0;
@ -16362,6 +16368,7 @@ class TCPDF {
break;
}
default: {
$parentSize = $this->getHTMLUnitToUnits($parent_size, $refsize, $defaultunit, true);
$size = $this->getHTMLUnitToUnits($val, $parent_size, $defaultunit, true);
}
}
@ -17743,7 +17750,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$pend = '';
}
}
if ((isset($plalign) AND ((($plalign == 'C') OR ($plalign == 'J') OR (($plalign == 'R') AND (!$this->rtl)) OR (($plalign == 'L') AND ($this->rtl)))))) {
if ((((($plalign == 'C') OR ($plalign == 'J') OR (($plalign == 'R') AND (!$this->rtl)) OR (($plalign == 'L') AND ($this->rtl)))))) {
// calculate shifting amount
$tw = $w;
if (($plalign == 'J') AND $this->isRTLTextDir() AND ($this->num_columns > 1)) {
@ -18349,7 +18356,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$dom[$trid]['cellpos'][($cellid - 1)]['bgcolor'] = $dom[$parentid]['bgcolor'];
}
// store border info
if (isset($tdborder) AND !empty($tdborder)) {
if (!empty($tdborder)) {
$dom[$trid]['cellpos'][($cellid - 1)]['border'] = $tdborder;
}
$prevLastH = $this->lasth;
@ -18585,7 +18592,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$strrest = $this->Write($this->lasth, $dom[$key]['value'], '', $wfill, '', false, 0, true, $firstblock, 0, $wadj);
// restore default direction
if ($reverse_dir AND ($wadj == 0)) {
$this->x = $xws;
$this->x = $xws; // @phpstan-ignore-line
$this->rtl = !$this->rtl;
$reverse_dir = false;
}
@ -18694,7 +18701,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$pend = '';
}
}
if ((isset($plalign) AND ((($plalign == 'C') OR (($plalign == 'R') AND (!$this->rtl)) OR (($plalign == 'L') AND ($this->rtl)))))) {
if ((((($plalign == 'C') OR (($plalign == 'R') AND (!$this->rtl)) OR (($plalign == 'L') AND ($this->rtl)))))) {
// calculate shifting amount
$tw = $w;
if ($this->lMargin != $prevlMargin) {
@ -19001,6 +19008,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
// data stream
$imgsrc = '@'.base64_decode(substr($imgsrc, 1));
$type = '';
} else if (preg_match('@^data:image/([^;]*);base64,(.*)@', $imgsrc, $reg)) {
$imgsrc = '@'.base64_decode($reg[2]);
$type = $reg[1];
} elseif ( $this->allowLocalFiles && substr($imgsrc, 0, 7) === 'file://') {
// get image type from a local file path
$imgsrc = substr($imgsrc, 7);
@ -19714,7 +19724,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$table_el = $dom[($dom[$key]['parent'])];
}
// for each row
if (count($table_el['trids']) > 0) {
if (!empty($table_el['trids'])) {
unset($xmax);
}
foreach ($table_el['trids'] as $j => $trkey) {
@ -23894,9 +23904,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
}
$firstcmd = false;
} // end foreach
if (!empty($op)) {
$this->_out($op);
}
$this->_out($op);
return array($xmin, $ymin, ($xmax - $xmin), ($ymax - $ymin));
}

View File

@ -175,7 +175,7 @@
<location>tcpdf</location>
<name>TCPDF</name>
<description>Class to generate PDF files</description>
<version>6.5.0</version>
<version>6.6.2</version>
<license>LGPL</license>
<licenseversion>3.0-only</licenseversion>
<repository>https://github.com/tecnickcom/TCPDF</repository>