| @@ -116,9 +116,13 @@ | ||
| 116 | 116 | $this->setSizesAndType($path); |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | // Check if a URL has been passed. https://stackoverflow.com/a/2058596/1252979 |
| 120 | - } elseif (filter_var($path, FILTER_VALIDATE_URL) || (preg_match('/^([\w\s\x00-\x1f]+):/u', $path) && !preg_match('/^([\w]+):/u', $path))) { | |
| 120 | + } elseif ( | |
| 121 | + filter_var($path, FILTER_VALIDATE_URL) | |
| 122 | + || Preg::isMatch('~^phar://~i', $path) | |
| 123 | + || (Preg::isMatch('/^([\w.\s\x00-\x1f]+):/', $path) && !Preg::isMatch('/^([\w.]+):/', $path)) | |
| 124 | + ) { | |
| 121 | 125 | if (!Preg::isMatch('/^(http|https|file|ftp|s3):/', $path)) { |
| 122 | 126 | throw new PhpSpreadsheetException('Invalid protocol for linked drawing'); |
| 123 | 127 | } |
| 124 | 128 | if (!$allowExternal) { |
| @@ -134,8 +138,9 @@ | ||
| 134 | 138 | // https://github.com/php/php-src/issues/17121 |
| 135 | 139 | if (str_starts_with($path, 'https:') || str_starts_with($path, 'http:')) { |
| 136 | 140 | $ctxArray = [ |
| 137 | 141 | 'http' => [ |
| 142 | + 'follow_location' => 0, | |
| 138 | 143 | 'user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36', |
| 139 | 144 | 'header' => [ |
| 140 | 145 | //'Connection: keep-alive', // unacceptable performance |
| 141 | 146 | 'Accept: image/*;q=0.9,*/*;q=0.8', |