Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for script tags in GIFs etc #3017

Merged
merged 1 commit into from Nov 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions Idno/Entities/File.php
Expand Up @@ -285,6 +285,20 @@ public static function isImage($file_path)
return false;
}

/**
* Detects whether the file contains PHP or script tags, eg to check for embedded code in GIFs
* @param $file_path
* @return bool
*/
public static function isFileFreeFromScriptTags($file_path)
{
if ($contents = file_get_contents($file_path)) {
if (stripos($contents, '<script') || strpos($contents, '<?')) return false;
return true;
}
return false;
}

/**
* Retrieve a file by ID
*
Expand Down