From 9e8861b4dc124c020ff63ab944cdba1ed22ccd65 Mon Sep 17 00:00:00 2001 From: Przemek Peron Date: Thu, 1 Oct 2020 20:27:02 +0200 Subject: [PATCH 01/10] Fix for PHP 7.4 --- tcpdf.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tcpdf.php b/tcpdf.php index 8b7d812..1ce3838 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -6866,6 +6866,12 @@ class TCPDF { list($x, $y) = $this->checkPageRegions($h, $x, $y); $exurl = ''; // external streams $imsize = FALSE; + + // Make sure the file variable is not empty or null because accessing $file[0] later + // results in error when running PHP 7.4 + if (empty($file)) { + return false; + } // check if we are passing an image as file or string if ($file[0] === '@') { // image from string From e5f4da5a76b44cd94740a5d293ae5558d5cb5443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Wed, 14 Oct 2020 10:33:59 +0200 Subject: [PATCH 02/10] Fix optionnal "$currentfont" parameter declaration --- include/tcpdf_fonts.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index 218fb6d..4f5bcf3 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -1995,7 +1995,7 @@ class TCPDF_FONTS { * @author Nicola Asuni * @public static */ - public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) { + public static function UTF8StringToArray($str, $isunicode=true, &$currentfont=array()) { if ($isunicode) { // requires PCRE unicode support turned on $chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY); @@ -2021,7 +2021,7 @@ class TCPDF_FONTS { * @since 3.2.000 (2008-06-23) * @public static */ - public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont) { + public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont=array()) { $unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values return self::UTF8ArrToLatin1($unicode); } @@ -2037,7 +2037,7 @@ class TCPDF_FONTS { * @since 1.53.0.TC005 (2005-01-05) * @public static */ - public static function UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont) { + public static function UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont=array()) { if (!$isunicode) { return $str; // string is not in unicode } @@ -2057,7 +2057,7 @@ class TCPDF_FONTS { * @since 2.1.000 (2008-01-08) * @public static */ - public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont) { + public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont=array()) { return self::utf8StrArrRev(self::UTF8StringToArray($str, $isunicode, $currentfont), $str, $setbom, $forcertl, $isunicode, $currentfont); } @@ -2074,7 +2074,7 @@ class TCPDF_FONTS { * @since 4.9.000 (2010-03-27) * @public static */ - public static function utf8StrArrRev($arr, $str='', $setbom=false, $forcertl=false, $isunicode=true, &$currentfont) { + public static function utf8StrArrRev($arr, $str='', $setbom=false, $forcertl=false, $isunicode=true, &$currentfont=array()) { return self::arrUTF8ToUTF16BE(self::utf8Bidi($arr, $str, $forcertl, $isunicode, $currentfont), $setbom); } @@ -2090,7 +2090,7 @@ class TCPDF_FONTS { * @since 2.4.000 (2008-03-06) * @public static */ - public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont) { + public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont=array()) { // paragraph embedding level $pel = 0; // max level From 292fc741f82f68283fd2d8171fc1ae92ff15b946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Wed, 14 Oct 2020 10:35:08 +0200 Subject: [PATCH 03/10] Fix optionnal "$k" parameter declaration --- include/tcpdf_static.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 06a1ddd..56af4a0 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -2507,7 +2507,7 @@ class TCPDF_STATIC { * @since 5.0.010 (2010-05-17) * @public static */ - public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array()) { + public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k=1, $pagedim=array()) { if (!isset($pagedim[$page])) { // initialize array $pagedim[$page] = array(); From 9616e9e44b111e79f6931763da265f05638aa839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Wed, 14 Oct 2020 10:35:46 +0200 Subject: [PATCH 04/10] Fix optionnal "$tagvspaces" parameter declaration --- include/tcpdf_static.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 56af4a0..56ea082 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -1136,7 +1136,7 @@ class TCPDF_STATIC { * @see setHtmlVSpace() * @public static */ - public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces) { + public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces=array()) { // configure parameters for HTML Tidy if ($tidy_options === '') { $tidy_options = array ( From 481e46d365cc03f81a8869e2639004ca00210de7 Mon Sep 17 00:00:00 2001 From: Yuya Yabe Date: Wed, 11 Nov 2020 15:44:33 +0900 Subject: [PATCH 05/10] Fix width calc --- tcpdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcpdf.php b/tcpdf.php index 8b7d812..2f30216 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -6489,7 +6489,7 @@ class TCPDF { // *** very slow *** $l = $this->GetArrStringWidth(TCPDF_FONTS::utf8Bidi(array_slice($chars, $j, ($i - $j)), '', $this->tmprtl, $this->isunicode, $this->CurrentFont)); } else { - $l += $this->GetCharWidth($c); + $l += $this->GetCharWidth($c, ($i+1 < $nb)); } if (($l > $wmax) OR (($c == 173) AND (($l + $tmp_shy_replacement_width) >= $wmax))) { if (($c == 173) AND (($l + $tmp_shy_replacement_width) > $wmax)) { From b1d592252550a924cd39f179c0293a43fce71801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 23 Nov 2020 10:57:57 +0100 Subject: [PATCH 06/10] Fix EOL of text files --- fonts/freefont-20100919/CREDITS | 2 +- fonts/freefont-20120503/CREDITS | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fonts/freefont-20100919/CREDITS b/fonts/freefont-20100919/CREDITS index 66396e7..0b69784 100644 --- a/fonts/freefont-20100919/CREDITS +++ b/fonts/freefont-20100919/CREDITS @@ -352,7 +352,7 @@ please contact mssridhar AT vsnl.com. Noah Levitt found out that the Sinhalese fonts available on the site are released under GNU GPL, or, -precisely, "Public Domain under GNU Licence Produced by DMS +precisely, "Public Domain under GNU Licence Produced by DMS Electronics for The Sri Lanka Tipitaka Project" (taken from the font comment), and took the effort of recoding the font to Unicode. diff --git a/fonts/freefont-20120503/CREDITS b/fonts/freefont-20120503/CREDITS index 06d280e..f4430ec 100644 --- a/fonts/freefont-20120503/CREDITS +++ b/fonts/freefont-20120503/CREDITS @@ -357,7 +357,7 @@ please contact mssridhar AT vsnl.com. Noah Levitt found out that the Sinhalese fonts available on the site are released under GNU GPL, or, -precisely, "Public Domain under GNU Licence Produced by DMS +precisely, "Public Domain under GNU Licence Produced by DMS Electronics for The Sri Lanka Tipitaka Project" (taken from the font comment), and took the effort of recoding the font to Unicode. From 65cc96b190d3e970ca882c12e1aa724376c63c37 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Sat, 23 Jan 2021 14:49:32 +0700 Subject: [PATCH 07/10] Curl Security: Limit protocols and redirects In `include/tcpdf_static.php` file, there are couple Curl calls that could use some additional Curl hardening. 1. Limit the maximum number of redirects Curl is allowed to follow. Currently, it is configured in PHP source code to 20. However, as a [security precaution, limit it to 5](https://php.watch/articles/php-curl-security-hardening#infinite-redirects). 2. Curl is used here for HTTP, HTTPS, and in one instance, for FTP URLs. With `CURLOPT_FOLLOWLOCATION` option enabled, this allows a malicious remote server to perform SSRF attacks and utilize all protocols Curl supports, such as LDAP, FTP, etc that are highly undesired. Setting a restricted [`CURLOPT_PROTOCOLS` value mitigates this vulnerability](https://php.watch/articles/php-curl-security-hardening#ssrf). In older Curl versions, it even allows local file inclusion attacks with `file:///etc/passwd` style redirect URLs. --- include/tcpdf_static.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 56ea082..20e5e4a 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -1842,6 +1842,10 @@ class TCPDF_STATIC { curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file'); + curl_setopt($crs, CURLOPT_MAXREDIRS, 5); + if (defined('CURLOPT_PROTOCOLS')) { + curl_setopt($crs, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP | CURLPROTO_FTP | CURLPROTO_FTPS); + } curl_exec($crs); $code = curl_getinfo($crs, CURLINFO_HTTP_CODE); curl_close($crs); @@ -1973,6 +1977,10 @@ class TCPDF_STATIC { curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file'); + curl_setopt($crs, CURLOPT_MAXREDIRS, 5); + if (defined('CURLOPT_PROTOCOLS')) { + curl_setopt($crs, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP | CURLPROTO_FTP | CURLPROTO_FTPS); + } $ret = curl_exec($crs); curl_close($crs); if ($ret !== false) { From e5c11046f83eeddd90aa4a7f2041dc0b6e5d4bbe Mon Sep 17 00:00:00 2001 From: Marc van Tilburg Date: Wed, 3 Mar 2021 10:13:36 +0100 Subject: [PATCH 08/10] PHP 8 (deprecation) fixes --- include/barcodes/pdf417.php | 2 +- include/barcodes/qrcode.php | 3 ++- include/tcpdf_colors.php | 2 +- include/tcpdf_fonts.php | 18 ++++++++++-------- include/tcpdf_static.php | 6 +++--- tcpdf_barcodes_1d.php | 8 ++++---- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/include/barcodes/pdf417.php b/include/barcodes/pdf417.php index 9a58a21..65381dc 100644 --- a/include/barcodes/pdf417.php +++ b/include/barcodes/pdf417.php @@ -740,6 +740,7 @@ class PDF417 { * @protected */ protected function getErrorCorrectionLevel($ecl, $numcw) { + $maxecl = 8; // starting error level // check for automatic levels if (($ecl < 0) OR ($ecl > 8)) { if ($numcw < 41) { @@ -755,7 +756,6 @@ class PDF417 { } } // get maximum correction level - $maxecl = 8; // starting error level $maxerrsize = (928 - $numcw); // available codewords for error while ($maxecl > 0) { $errsize = (2 << $ecl); diff --git a/include/barcodes/qrcode.php b/include/barcodes/qrcode.php index 7ef2759..a9a2124 100644 --- a/include/barcodes/qrcode.php +++ b/include/barcodes/qrcode.php @@ -1386,6 +1386,7 @@ class QRcode { $p += 2; } $this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr)); + $run = $p; return $run; } @@ -1455,7 +1456,7 @@ class QRcode { break; } case QR_MODE_KJ: { - if ($hint == QR_MODE_KJ) { + if ($this->hint == QR_MODE_KJ) { $length = $this->eatKanji(); } else { $length = $this->eat8(); diff --git a/include/tcpdf_colors.php b/include/tcpdf_colors.php index 27fb7af..f9fc3fc 100644 --- a/include/tcpdf_colors.php +++ b/include/tcpdf_colors.php @@ -449,7 +449,7 @@ class TCPDF_COLORS { } if (!in_array($color, self::$jscolor)) { // default transparent color - $color = $jscolor[0]; + $color = self::$jscolor[0]; } return 'color.'.$color; } diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index 4f5bcf3..bd1cc77 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -557,6 +557,7 @@ class TCPDF_FONTS { $numGlyphs = TCPDF_STATIC::_getUSHORT($font, $offset); // ---------- get CIDToGIDMap ---------- $ctg = array(); + $c = 0; foreach ($encodingTables as $enctable) { // get only specified Platform ID and Encoding ID if (($enctable['platformID'] == $platid) AND ($enctable['encodingID'] == $encid)) { @@ -956,6 +957,7 @@ class TCPDF_FONTS { // sfnt version must be 0x00010000 for TrueType version 1.0. return $font; } + $c = 0; $offset += 4; // get number of tables $numTables = TCPDF_STATIC::_getUSHORT($font, $offset); @@ -1883,7 +1885,7 @@ class TCPDF_FONTS { * Converts UTF-8 character to integer value.
* Uses the getUniord() method if the value is not cached. * @param $uch (string) character string to process. - * @return integer Unicode value + * @return int Unicode value * @public static */ public static function uniord($uch) { @@ -1922,7 +1924,7 @@ class TCPDF_FONTS { * --------------------------------------------------------------------- * * @param $uch (string) character string to process. - * @return integer Unicode value + * @return int Unicode value * @author Nicola Asuni * @public static */ @@ -1995,7 +1997,7 @@ class TCPDF_FONTS { * @author Nicola Asuni * @public static */ - public static function UTF8StringToArray($str, $isunicode=true, &$currentfont=array()) { + public static function UTF8StringToArray($str, $isunicode, &$currentfont) { if ($isunicode) { // requires PCRE unicode support turned on $chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY); @@ -2021,7 +2023,7 @@ class TCPDF_FONTS { * @since 3.2.000 (2008-06-23) * @public static */ - public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont=array()) { + public static function UTF8ToLatin1($str, $isunicode, &$currentfont) { $unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values return self::UTF8ArrToLatin1($unicode); } @@ -2037,7 +2039,7 @@ class TCPDF_FONTS { * @since 1.53.0.TC005 (2005-01-05) * @public static */ - public static function UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont=array()) { + public static function UTF8ToUTF16BE($str, $setbom, $isunicode, &$currentfont) { if (!$isunicode) { return $str; // string is not in unicode } @@ -2057,7 +2059,7 @@ class TCPDF_FONTS { * @since 2.1.000 (2008-01-08) * @public static */ - public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont=array()) { + public static function utf8StrRev($str, $setbom, $forcertl, $isunicode, &$currentfont) { return self::utf8StrArrRev(self::UTF8StringToArray($str, $isunicode, $currentfont), $str, $setbom, $forcertl, $isunicode, $currentfont); } @@ -2074,7 +2076,7 @@ class TCPDF_FONTS { * @since 4.9.000 (2010-03-27) * @public static */ - public static function utf8StrArrRev($arr, $str='', $setbom=false, $forcertl=false, $isunicode=true, &$currentfont=array()) { + public static function utf8StrArrRev($arr, $str, $setbom, $forcertl, $isunicode, &$currentfont) { return self::arrUTF8ToUTF16BE(self::utf8Bidi($arr, $str, $forcertl, $isunicode, $currentfont), $setbom); } @@ -2090,7 +2092,7 @@ class TCPDF_FONTS { * @since 2.4.000 (2008-03-06) * @public static */ - public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont=array()) { + public static function utf8Bidi($ta, $str, $forcertl, $isunicode, &$currentfont) { // paragraph embedding level $pel = 0; // max level diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 56ea082..6985b09 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -276,7 +276,7 @@ class TCPDF_STATIC { /** * Determine whether a string is empty. * @param $str (string) string to be checked - * @return boolean true if string is empty + * @return bool true if string is empty * @since 4.5.044 (2009-04-16) * @public static */ @@ -1136,7 +1136,7 @@ class TCPDF_STATIC { * @see setHtmlVSpace() * @public static */ - public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces=array()) { + public static function fixHTMLCode($html, $default_css, $tagvs, $tidy_options, &$tagvspaces) { // configure parameters for HTML Tidy if ($tidy_options === '') { $tidy_options = array ( @@ -2507,7 +2507,7 @@ class TCPDF_STATIC { * @since 5.0.010 (2010-05-17) * @public static */ - public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k=1, $pagedim=array()) { + public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points, $k, $pagedim=array()) { if (!isset($pagedim[$page])) { // initialize array $pagedim[$page] = array(); diff --git a/tcpdf_barcodes_1d.php b/tcpdf_barcodes_1d.php index 78bfc5b..2b94afc 100644 --- a/tcpdf_barcodes_1d.php +++ b/tcpdf_barcodes_1d.php @@ -938,7 +938,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq[$j]; + $w = (float)$seq[$j]; $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); $bararray['maxw'] += $w; ++$k; @@ -1271,7 +1271,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq[$j]; + $w = (float)$seq[$j]; $bararray['bcode'][] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); $bararray['maxw'] += $w; } @@ -1856,7 +1856,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq[$j]; + $w = (float)$seq[$j]; $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); $bararray['maxw'] += $w; ++$k; @@ -1947,7 +1947,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq[$j]; + $w = (float)$seq[$j]; $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); $bararray['maxw'] += $w; ++$k; From 0eb62a7d5f7ef02bb280e5f78b477604fc41ca91 Mon Sep 17 00:00:00 2001 From: Den Date: Fri, 26 Mar 2021 13:56:12 +0300 Subject: [PATCH 09/10] Fixed large count of notices --- tcpdf.php | 65 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/tcpdf.php b/tcpdf.php index f833ebe..63370ce 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -2728,7 +2728,7 @@ class TCPDF { /** * Adjust the internal Cell padding array to take account of the line width. * @param $brd (mixed) Indicates if borders must be drawn around the cell. The value can be a number:
  • 0: no border (default)
  • 1: frame
or a string containing some or all of the following characters (in any order):
  • L: left
  • T: top
  • R: right
  • B: bottom
or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))) - * @return array of adjustments + * @return void|array of adjustments * @public * @since 5.9.000 (2010-10-03) */ @@ -2744,7 +2744,11 @@ class TCPDF { $newbrd[$brd[$i]] = true; } $brd = $newbrd; - } elseif (($brd === 1) OR ($brd === true) OR (is_numeric($brd) AND (intval($brd) > 0))) { + } elseif ( + ($brd === 1) + || ($brd === true) + || (is_numeric($brd) && ((int)$brd > 0)) + ) { $brd = array('LRTB' => true); } if (!is_array($brd)) { @@ -2762,7 +2766,7 @@ class TCPDF { // process borders foreach ($brd as $border => $style) { $line_width = $this->LineWidth; - if (is_array($style) AND isset($style['width'])) { + if (is_array($style) && isset($style['width'])) { // get border width $line_width = $style['width']; } @@ -2783,20 +2787,43 @@ class TCPDF { } } // correct internal cell padding if required to avoid overlap between text and lines - if ((strpos($border,'T') !== false) AND ($this->cell_padding['T'] < $adj)) { + if ( + is_numeric($this->cell_padding['T']) + && ($this->cell_padding['T'] < $adj) + && (strpos($border, 'T') !== false) + ) { $this->cell_padding['T'] = $adj; } - if ((strpos($border,'R') !== false) AND ($this->cell_padding['R'] < $adj)) { + if ( + is_numeric($this->cell_padding['R']) + && ($this->cell_padding['R'] < $adj) + && (strpos($border, 'R') !== false) + ) { $this->cell_padding['R'] = $adj; } - if ((strpos($border,'B') !== false) AND ($this->cell_padding['B'] < $adj)) { + if ( + is_numeric($this->cell_padding['B']) + && ($this->cell_padding['B'] < $adj) + && (strpos($border, 'B') !== false) + ) { $this->cell_padding['B'] = $adj; } - if ((strpos($border,'L') !== false) AND ($this->cell_padding['L'] < $adj)) { + if ( + is_numeric($this->cell_padding['L']) + && ($this->cell_padding['L'] < $adj) + && (strpos($border, 'L') !== false) + ) { $this->cell_padding['L'] = $adj; } + } - return array('T' => ($this->cell_padding['T'] - $cp['T']), 'R' => ($this->cell_padding['R'] - $cp['R']), 'B' => ($this->cell_padding['B'] - $cp['B']), 'L' => ($this->cell_padding['L'] - $cp['L'])); + + return array( + 'T' => ($this->cell_padding['T'] - $cp['T']), + 'R' => ($this->cell_padding['R'] - $cp['R']), + 'B' => ($this->cell_padding['B'] - $cp['B']), + 'L' => ($this->cell_padding['L'] - $cp['L']), + ); } /** @@ -16555,7 +16582,11 @@ class TCPDF { $dom[($dom[$key]['parent'])]['content'] = str_replace('', '', $dom[($dom[$key]['parent'])]['content']); } // store header rows on a new table - if (($dom[$key]['value'] == 'tr') AND ($dom[($dom[$key]['parent'])]['thead'] === true)) { + if ( + ($dom[$key]['value'] === 'tr') + && !empty($dom[($dom[$key]['parent'])]['thead']) + && ($dom[($dom[$key]['parent'])]['thead'] === true) + ) { if (TCPDF_STATIC::empty_string($dom[($dom[($dom[$key]['parent'])]['parent'])]['thead'])) { $dom[($dom[($dom[$key]['parent'])]['parent'])]['thead'] = $csstagarray.$a[$dom[($dom[($dom[$key]['parent'])]['parent'])]['elkey']]; } @@ -16985,10 +17016,20 @@ class TCPDF { // rows on thead block are printed as a separate table } else { $dom[$key]['thead'] = false; + $parent = $dom[$key]['parent']; + + if (!isset($dom[$parent]['rows'])) { + $dom[$parent]['rows'] = 0; + } // store the number of rows on table element - ++$dom[($dom[$key]['parent'])]['rows']; + ++$dom[$parent]['rows']; + + if (!isset($dom[$parent]['trids'])) { + $dom[$parent]['trids'] = array(); + } + // store the TR elements IDs on table element - array_push($dom[($dom[$key]['parent'])]['trids'], $key); + array_push($dom[$parent]['trids'], $key); } } if (($dom[$key]['value'] == 'th') OR ($dom[$key]['value'] == 'td')) { @@ -19813,7 +19854,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } } if (!$in_table_head) { // we are not inside a thead section - $this->cell_padding = $table_el['old_cell_padding']; + $this->cell_padding = isset($table_el['old_cell_padding']) ? $table_el['old_cell_padding'] : null; // reset row height $this->resetLastH(); if (($this->page == ($this->numpages - 1)) AND ($this->pageopen[$this->numpages])) { From 3b1b0638765395506b720ee24dc531b4fdd1812f Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sat, 27 Mar 2021 08:30:57 +0000 Subject: [PATCH 10/10] ignore .phpdoc --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 723ef36..ecd8206 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -.idea \ No newline at end of file +.idea +.phpdoc +*.bak