Skip to content

Commit a5cec95

Browse files
authored
Merge pull request PrestaShop#37828 from M0rgan01/validate-url
Add URL Validation when installing theme from URL
2 parents d7e2539 + c1bf16e commit a5cec95

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

classes/Tools.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,13 @@ public static function file_get_contents(
21072107
*/
21082108
public static function createFileFromUrl($url)
21092109
{
2110+
//TODO use Validate::isUrl instead when it will be less permissive and also allows schemes to be validated
2111+
$scheme = parse_url($url, PHP_URL_SCHEME);
2112+
2113+
// Check if the scheme is allowed
2114+
if (!in_array(strtolower($scheme), ['http', 'https'], true)) {
2115+
return false;
2116+
}
21102117
$remoteFile = fopen($url, 'rb');
21112118
if (!$remoteFile) {
21122119
return false;

0 commit comments

Comments
 (0)