|
1 | 1 | <?php |
2 | 2 | //============================================================+ |
3 | 3 | // File name : tcpdf.php |
4 | | -// Version : 6.9.0 |
| 4 | +// Version : 6.9.1 |
5 | 5 | // Begin : 2002-08-03 |
6 | | -// Last Update : 2025-03-30 |
| 6 | +// Last Update : 2025-04-03 |
7 | 7 | // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected] |
8 | 8 | // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) |
9 | 9 | // ------------------------------------------------------------------- |
|
104 | 104 | * Tools to encode your unicode fonts are on fonts/utils directory.</p> |
105 | 105 | * @package com.tecnick.tcpdf |
106 | 106 | * @author Nicola Asuni |
107 | | - * @version 6.9.0 |
| 107 | + * @version 6.9.1 |
108 | 108 | */ |
109 | 109 |
|
110 | 110 | // TCPDF configuration |
|
128 | 128 | * 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> |
129 | 129 | * @package com.tecnick.tcpdf |
130 | 130 | * @brief PHP class for generating PDF documents without requiring external extensions. |
131 | | - * @version 6.9.0 |
| 131 | + * @version 6.9.1 |
132 | 132 | * @author Nicola Asuni - [email protected] |
133 | 133 | * @IgnoreAnnotation("protected") |
134 | 134 | * @IgnoreAnnotation("public") |
@@ -18868,6 +18868,17 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal |
18868 | 18868 | unset($dom); |
18869 | 18869 | } |
18870 | 18870 |
|
| 18871 | + /** |
| 18872 | + * Check if the path is relative. |
| 18873 | + * @param string $path path to check |
| 18874 | + * @return boolean true if the path is relative |
| 18875 | + * @protected |
| 18876 | + * @since 6.9.1 |
| 18877 | + */ |
| 18878 | + protected function isRelativePath($path) { |
| 18879 | + return (strpos(str_ireplace('%2E', '.', $this->unhtmlentities($path)), '..') !== false); |
| 18880 | + } |
| 18881 | + |
18871 | 18882 | /** |
18872 | 18883 | * Process opening tags. |
18873 | 18884 | * @param array $dom html dom array |
@@ -19060,7 +19071,7 @@ protected function openHTMLTagHandler($dom, $key, $cell) { |
19060 | 19071 | } else if (preg_match('@^data:image/([^;]*);base64,(.*)@', $imgsrc, $reg)) { |
19061 | 19072 | $imgsrc = '@'.base64_decode($reg[2]); |
19062 | 19073 | $type = $reg[1]; |
19063 | | - } elseif (strpos($imgsrc, '../') !== false) { |
| 19074 | + } elseif ($this->isRelativePath($imgsrc)) { |
19064 | 19075 | // accessing parent folders is not allowed |
19065 | 19076 | break; |
19066 | 19077 | } elseif ( $this->allowLocalFiles && substr($imgsrc, 0, 7) === 'file://') { |
@@ -24467,7 +24478,7 @@ protected function startSVGElementHandler($parser, $name, $attribs, $ctm=array() |
24467 | 24478 | $img = '@'.base64_decode(substr($img, strlen($m[0]))); |
24468 | 24479 | } else { |
24469 | 24480 | // fix image path |
24470 | | - if (strpos($img, '../') !== false) { |
| 24481 | + if ($this->isRelativePath($img)) { |
24471 | 24482 | // accessing parent folders is not allowed |
24472 | 24483 | break; |
24473 | 24484 | } |
|
0 commit comments