Skip to content

Commit 05d20bb

Browse files
committed
Update TCPDF version used to latest one, replace deprecated each function.
1 parent c7c8bf4 commit 05d20bb

File tree

12 files changed

+456
-299
lines changed

12 files changed

+456
-299
lines changed

tcpdf/CHANGELOG.TXT

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
6.2.25
2+
- Fix support for image URLs.
3+
4+
6.2.24
5+
- Support remote urls when checking if file exists.
6+
7+
6.2.23
8+
- Simplify file_exists function.
9+
10+
6.2.22
11+
- Fix for security vulnerability: Using the phar:// wrapper it was possible to trigger the unserialization of user provided data.
12+
13+
6.2.19
14+
- Merge various fixes for PHP 7.3 compatibility and security.
15+
16+
6.2.13 (2016-06-10)
17+
- IMPORTANT: A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable.
18+
119
6.2.12 (2015-09-12)
220
- fix composer package name to tecnickcom/tcpdf
321

tcpdf/LICENSE.TXT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
under the terms of the GNU Lesser General Public License as
77
published by the Free Software Foundation, either version 3 of the
88
License, or (at your option) any later version.
9+
10+
2002-2019 Nicola Asuni - Tecnick.com LTD
911

1012
**********************************************************************
1113
**********************************************************************

tcpdf/composer.json

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
11
{
2-
"name": "tecnickcom/tcpdf",
3-
"version": "6.2.12",
4-
"homepage": "http://www.tcpdf.org/",
5-
"type": "library",
6-
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
7-
"keywords": ["PDF","tcpdf","PDFD32000-2008","qrcode","datamatrix","pdf417","barcodes"],
8-
"license": "LGPLv3",
9-
"authors": [
10-
{
11-
"name": "Nicola Asuni",
12-
"email": "info@tecnick.com",
13-
"homepage": "http://nicolaasuni.tecnick.com"
14-
}
15-
],
16-
"require": {
17-
"php": ">=5.3.0"
18-
},
19-
"autoload": {
20-
"classmap": [
21-
"fonts",
22-
"config",
23-
"include",
24-
"tcpdf.php",
25-
"tcpdf_parser.php",
26-
"tcpdf_import.php",
27-
"tcpdf_barcodes_1d.php",
28-
"tcpdf_barcodes_2d.php",
29-
"include/tcpdf_colors.php",
30-
"include/tcpdf_filters.php",
31-
"include/tcpdf_font_data.php",
32-
"include/tcpdf_fonts.php",
33-
"include/tcpdf_images.php",
34-
"include/tcpdf_static.php",
35-
"include/barcodes/datamatrix.php",
36-
"include/barcodes/pdf417.php",
37-
"include/barcodes/qrcode.php"
38-
]
39-
}
2+
"name": "tecnickcom/tcpdf",
3+
"version": "6.3.5",
4+
"homepage": "http://www.tcpdf.org/",
5+
"type": "library",
6+
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
7+
"keywords": [
8+
"PDF",
9+
"tcpdf",
10+
"PDFD32000-2008",
11+
"qrcode",
12+
"datamatrix",
13+
"pdf417",
14+
"barcodes"
15+
],
16+
"license": "LGPL-3.0-only",
17+
"authors": [
18+
{
19+
"name": "Nicola Asuni",
20+
"email": "info@tecnick.com",
21+
"role": "lead"
22+
}
23+
],
24+
"require": {
25+
"php": ">=5.3.0"
26+
},
27+
"autoload": {
28+
"classmap": [
29+
"config",
30+
"include",
31+
"tcpdf.php",
32+
"tcpdf_parser.php",
33+
"tcpdf_import.php",
34+
"tcpdf_barcodes_1d.php",
35+
"tcpdf_barcodes_2d.php",
36+
"include/tcpdf_colors.php",
37+
"include/tcpdf_filters.php",
38+
"include/tcpdf_font_data.php",
39+
"include/tcpdf_fonts.php",
40+
"include/tcpdf_images.php",
41+
"include/tcpdf_static.php",
42+
"include/barcodes/datamatrix.php",
43+
"include/barcodes/pdf417.php",
44+
"include/barcodes/qrcode.php"
45+
]
46+
}
4047
}

tcpdf/include/barcodes/pdf417.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -740,16 +740,6 @@ public function getBarcodeArray() {
740740
* @protected
741741
*/
742742
protected function getErrorCorrectionLevel($ecl, $numcw) {
743-
// get maximum correction level
744-
$maxecl = 8; // starting error level
745-
$maxerrsize = (928 - $numcw); // available codewords for error
746-
while ($maxecl > 0) {
747-
$errsize = (2 << $ecl);
748-
if ($maxerrsize >= $errsize) {
749-
break;
750-
}
751-
--$maxecl;
752-
}
753743
// check for automatic levels
754744
if (($ecl < 0) OR ($ecl > 8)) {
755745
if ($numcw < 41) {
@@ -764,6 +754,16 @@ protected function getErrorCorrectionLevel($ecl, $numcw) {
764754
$ecl = $maxecl;
765755
}
766756
}
757+
// get maximum correction level
758+
$maxecl = 8; // starting error level
759+
$maxerrsize = (928 - $numcw); // available codewords for error
760+
while ($maxecl > 0) {
761+
$errsize = (2 << $ecl);
762+
if ($maxerrsize >= $errsize) {
763+
break;
764+
}
765+
--$maxecl;
766+
}
767767
if ($ecl > $maxecl) {
768768
$ecl = $maxecl;
769769
}

tcpdf/include/tcpdf_colors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R'
358358
$color_code = self::$webcolor[$color];
359359
} else {
360360
// spot color
361-
$returncolor = self::getSpotColor($color, $spotc);
361+
$returncolor = self::getSpotColor($hcolor, $spotc);
362362
if ($returncolor === false) {
363363
$returncolor = $defcol;
364364
}

tcpdf/include/tcpdf_fonts.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class TCPDF_FONTS {
7070
* @public static
7171
*/
7272
public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) {
73-
if (!file_exists($fontfile)) {
73+
if (!TCPDF_STATIC::file_exists($fontfile)) {
7474
// Could not find file
7575
return false;
7676
}
@@ -95,7 +95,7 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $
9595
$outpath = self::_getfontpath();
9696
}
9797
// check if this font already exist
98-
if (@file_exists($outpath.$font_name.'.php')) {
98+
if (@TCPDF_STATIC::file_exists($outpath.$font_name.'.php')) {
9999
// this font already exist (delete it from fonts folder to rebuild it)
100100
return $font_name;
101101
}
@@ -665,7 +665,7 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $
665665
$glyphIdArray[$k] = TCPDF_STATIC::_getUSHORT($font, $offset);
666666
$offset += 2;
667667
}
668-
for ($k = 0; $k < $segCount; ++$k) {
668+
for ($k = 0; $k < $segCount - 1; ++$k) {
669669
for ($c = $startCount[$k]; $c <= $endCount[$k]; ++$c) {
670670
if ($idRangeOffset[$k] == 0) {
671671
$g = ($idDelta[$k] + $c) % 65536;
@@ -1543,11 +1543,11 @@ public static function _getfontpath() {
15431543
public static function getFontFullPath($file, $fontdir=false) {
15441544
$fontfile = '';
15451545
// search files on various directories
1546-
if (($fontdir !== false) AND @file_exists($fontdir.$file)) {
1546+
if (($fontdir !== false) AND @TCPDF_STATIC::file_exists($fontdir.$file)) {
15471547
$fontfile = $fontdir.$file;
1548-
} elseif (@file_exists(self::_getfontpath().$file)) {
1548+
} elseif (@TCPDF_STATIC::file_exists(self::_getfontpath().$file)) {
15491549
$fontfile = self::_getfontpath().$file;
1550-
} elseif (@file_exists($file)) {
1550+
} elseif (@TCPDF_STATIC::file_exists($file)) {
15511551
$fontfile = $file;
15521552
}
15531553
return $fontfile;
@@ -1664,9 +1664,8 @@ public static function getFontRefSize($size, $refsize=12) {
16641664
* @public static
16651665
*/
16661666
public static function unichr($c, $unicode=true) {
1667-
if (is_null($c) || !strlen($c)) {
1668-
return '';
1669-
} elseif (!$unicode) {
1667+
$c = intval($c);
1668+
if (!$unicode) {
16701669
return chr($c);
16711670
} elseif ($c <= 0x7F) {
16721671
// one byte
@@ -2005,7 +2004,11 @@ public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) {
20052004
$chars = str_split($str);
20062005
$carr = array_map('ord', $chars);
20072006
}
2008-
$currentfont['subsetchars'] += array_fill_keys($carr, true);
2007+
if (is_array($currentfont['subsetchars']) && is_array($carr)) {
2008+
$currentfont['subsetchars'] += array_fill_keys($carr, true);
2009+
} else {
2010+
$currentfont['subsetchars'] = array_merge($currentfont['subsetchars'], $carr);
2011+
}
20092012
return $carr;
20102013
}
20112014

tcpdf/include/tcpdf_images.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,8 @@ public static function _toJPEG($image, $quality, $tempfile) {
161161
*/
162162
public static function _parsejpeg($file) {
163163
// check if is a local file
164-
if (!@file_exists($file)) {
165-
// try to encode spaces on filename
166-
$tfile = str_replace(' ', '%20', $file);
167-
if (@file_exists($tfile)) {
168-
$file = $tfile;
169-
}
164+
if (!@TCPDF_STATIC::file_exists($file)) {
165+
return false;
170166
}
171167
$a = getimagesize($file);
172168
if (empty($a)) {

0 commit comments

Comments
 (0)