start implementing strict comparison

This commit is contained in:
Dennis Eichhorn 2023-10-23 01:31:11 +00:00
parent e71a79ec95
commit 937fa14da3
2 changed files with 281 additions and 281 deletions

File diff suppressed because it is too large Load Diff

View File

@ -73,14 +73,14 @@ class TCPDF_IMAGES {
$type = ''; $type = '';
if (isset($iminfo['mime']) && !empty($iminfo['mime'])) { if (isset($iminfo['mime']) && !empty($iminfo['mime'])) {
$mime = \explode('/', $iminfo['mime']); $mime = \explode('/', $iminfo['mime']);
if ((\count($mime) > 1) && ($mime[0] == 'image') && (!empty($mime[1]))) { if ((\count($mime) > 1) && ($mime[0] === 'image') && (!empty($mime[1]))) {
$type = \strtolower(\trim($mime[1])); $type = \strtolower(\trim($mime[1]));
} }
} }
if (empty($type)) { if (empty($type)) {
$type = \strtolower(\trim(\pathinfo(\parse_url($imgfile, \PHP_URL_PATH), \PATHINFO_EXTENSION))); $type = \strtolower(\trim(\pathinfo(\parse_url($imgfile, \PHP_URL_PATH), \PATHINFO_EXTENSION)));
} }
if ($type == 'jpg') { if ($type === 'jpg') {
$type = 'jpeg'; $type = 'jpeg';
} }
return $type; return $type;
@ -294,11 +294,11 @@ class TCPDF_IMAGES {
$n = TCPDF_STATIC::_freadint($f); $n = TCPDF_STATIC::_freadint($f);
do { do {
$type = \fread($f, 4); $type = \fread($f, 4);
if ($type == 'PLTE') { if ($type === 'PLTE') {
// read palette // read palette
$pal = TCPDF_STATIC::rfread($f, $n); $pal = TCPDF_STATIC::rfread($f, $n);
\fread($f, 4); \fread($f, 4);
} elseif ($type == 'tRNS') { } elseif ($type === 'tRNS') {
// read transparency info // read transparency info
$t = TCPDF_STATIC::rfread($f, $n); $t = TCPDF_STATIC::rfread($f, $n);
if ($ct == 0) { // DeviceGray if ($ct == 0) { // DeviceGray
@ -314,11 +314,11 @@ class TCPDF_IMAGES {
} }
} }
\fread($f, 4); \fread($f, 4);
} elseif ($type == 'IDAT') { } elseif ($type === 'IDAT') {
// read image data block // read image data block
$data .= TCPDF_STATIC::rfread($f, $n); $data .= TCPDF_STATIC::rfread($f, $n);
\fread($f, 4); \fread($f, 4);
} elseif ($type == 'iCCP') { } elseif ($type === 'iCCP') {
// skip profile name // skip profile name
$len = 0; $len = 0;
while ((\ord(\fread($f, 1)) != 0) && ($len < 80)) { while ((\ord(\fread($f, 1)) != 0) && ($len < 80)) {
@ -335,14 +335,14 @@ class TCPDF_IMAGES {
// decompress profile // decompress profile
$icc = \gzuncompress($icc); $icc = \gzuncompress($icc);
\fread($f, 4); \fread($f, 4);
} elseif ($type == 'IEND') { } elseif ($type === 'IEND') {
break; break;
} else { } else {
TCPDF_STATIC::rfread($f, $n + 4); TCPDF_STATIC::rfread($f, $n + 4);
} }
$n = TCPDF_STATIC::_freadint($f); $n = TCPDF_STATIC::_freadint($f);
} while ($n); } while ($n);
if (($colspace == 'Indexed') && (empty($pal))) { if (($colspace === 'Indexed') && (empty($pal))) {
// Missing palette // Missing palette
\fclose($f); \fclose($f);
return false; return false;