Issues

ZF-10006: Zend_Captcha_Image::_gc() does not consider file suffix

Issue Type: Bug Created: 2010-06-17T10:34:38.000+0000 Last Updated: 2010-07-16T17:56:55.000+0000 Status: Resolved Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Rodrigo Primo (rodrigosprimo) Assignee: Mickael Perraud (mikaelkael) Tags: - Zend_Captcha

Related issues: Attachments: - Image.php.patch

Description

The garbage collector for Zend_Captcha_Image (Zend_Captcha_Image::_gc()) deletes all the files inside the directory used to store the captcha's images (including hidden files). This is a problem if you want to use a directory that is used by other parts of your application.

Bellow a patch that fix the issue. With this change the garbage collector will only delete files that match the suffix.

<pre class="highlight">
--- Image.php   2010-06-17 13:25:20.000000000 -0400
+++ Image.php   2010-06-17 13:25:16.000000000 -0400
@@ -580,7 +580,11 @@
         foreach (new DirectoryIterator($imgdir) as $file) {
             if (!$file->isDot() && !$file->isDir()) {
                 if ($file->getMTime() < $expire) {
-                    unlink($file->getPathname());
+                    $len = strlen($this->_suffix);
+                    // only deletes files ending with $this->_suffix
+                    if (substr($file->getFilename(), -($len), $len) == $this->_suffix) {
+                        unlink($file->getPathname());
+                    }
                 }
             }
         }

Comments

Posted by Rodrigo Primo (rodrigosprimo) on 2010-06-17T10:37:19.000+0000

The same patcha provide in the bug description

Posted by Mickael Perraud (mikaelkael) on 2010-07-16T13:54:22.000+0000

Fixed in trunk with r22589 and applied on 1.10 branch with r22590

Posted by Rodrigo Primo (rodrigosprimo) on 2010-07-16T17:56:55.000+0000

Thanks :-)

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts