Skip to content

Commit

Permalink
Merge pull request PrestaShop#37828 from M0rgan01/validate-url
Browse files Browse the repository at this point in the history
Add URL Validation when installing theme from URL
  • Loading branch information
M0rgan01 authored Jan 23, 2025
2 parents d7e2539 + c1bf16e commit a5cec95
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions classes/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,13 @@ public static function file_get_contents(
*/
public static function createFileFromUrl($url)
{
//TODO use Validate::isUrl instead when it will be less permissive and also allows schemes to be validated
$scheme = parse_url($url, PHP_URL_SCHEME);

// Check if the scheme is allowed
if (!in_array(strtolower($scheme), ['http', 'https'], true)) {
return false;
}
$remoteFile = fopen($url, 'rb');
if (!$remoteFile) {
return false;
Expand Down

0 comments on commit a5cec95

Please sign in to comment.