MDL-68047 tcpdf: Prevent images out from cache to be removed
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Sun, 8 Mar 2020 17:48:16 +0000 (18:48 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Sun, 5 Apr 2020 22:29:55 +0000 (00:29 +0200)
This corresponds to https://github.com/tecnickcom/TCPDF/pull/174
(and was fixed bycommit 510070b) and was a regression causing
image files to be removed unconditionally. Only if the images
are from cache, they can be removed.

It's fixed upstream in version 6.3.4 and up.

lib/tcpdf/readme_moodle.txt
lib/tcpdf/tcpdf.php

index d25b1ff..ee3863a 100644 (file)
@@ -9,6 +9,7 @@ Description of TCPDF library import 6.3.2
   * 18dabac - https://git.io/JeKfU
   * 60c9db7 - https://git.io/JeKfT
   * 1adcd76 - https://git.io/JeKft
+  * 5e4d999 - https://git.io/JvrxB
 * visit http://127.0.0.1/lib/tests/other/pdflibtestpage.php and view the pdf
 
 Important
index 45ea18e..ed30431 100644 (file)
@@ -7798,7 +7798,9 @@ class TCPDF {
                        }
                        if (isset($this->imagekeys)) {
                                foreach($this->imagekeys as $file) {
-                                       unlink($file);
+                                       if (strpos($file, K_PATH_CACHE) === 0) {
+                                               unlink($file);
+                                       }
                                }
                        }
                }