Slightly robuster test
Also, single quotes per style conventions
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 57ef9e2..3aac14d 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -80,7 +80,7 @@
$current_dir = @opendir($img_path);
while ($filename = @readdir($current_dir))
{
- if (strpos($filename, ".jpg") !== FALSE && (str_replace('.jpg', '', $filename) + $expiration) < $now)
+ if (substr($filename, -4) === '.jpg' && (str_replace('.jpg', '', $filename) + $expiration) < $now)
{
@unlink($img_path.$filename);
}