diff options
| author | Syndamia <kamen@syndamia.com> | 2025-02-12 11:49:35 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-02-12 11:49:35 +0200 |
| commit | 6ca7ecdfab2b92bd9ee0a18d286e9b73b145634a (patch) | |
| tree | 06610006bd2efc269d3cdc0e729400ba61689c93 /controllers/archive.php | |
| parent | 0d7b597123aa7227bd130d44fb6ec4cfb06c97a2 (diff) | |
| download | nowayforward_human-6ca7ecdfab2b92bd9ee0a18d286e9b73b145634a.tar nowayforward_human-6ca7ecdfab2b92bd9ee0a18d286e9b73b145634a.tar.gz nowayforward_human-6ca7ecdfab2b92bd9ee0a18d286e9b73b145634a.zip | |
hotfix: Fix resource names on windows with incompatible characters
Diffstat (limited to 'controllers/archive.php')
| -rw-r--r-- | controllers/archive.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/controllers/archive.php b/controllers/archive.php index 8ef8dbf..ee2d63e 100644 --- a/controllers/archive.php +++ b/controllers/archive.php @@ -200,6 +200,11 @@ class DownloadPage { $sourceContent = $this->downloadFile($currentLink); if ($sourceContent) { $resourceName = basename($currentName); + $resourceName = str_replace( + ['/', '\\', '?', '*', '|', ':', '"', "'", '=', '<', '>'], + '', + $resourceName + ); $folder_path = $this->folder_location . '/' . $this->folder_name; $file = fopen($folder_path . '/' . $resourceName, "w"); if ($file){ @@ -313,6 +318,11 @@ class DownloadPage { if ($this->isResourceAccessible($url)) { // Get the file name and local path $file_name = basename($url); + $file_name = str_replace( + ['/', '\\', '?', '*', '|', ':', '"', "'", '=', '<', '>'], + '', + $file_name + ); $file_path = './' . $file_name; $folder_path = $this->folder_location . '/' . $this->folder_name; $urlContents = $this->downloadFile($url); @@ -345,6 +355,11 @@ class DownloadPage { if ($this->isResourceAccessible($url)) { // Get the file name and local path $file_name = basename($url); + $file_name = str_replace( + ['/', '\\', '?', '*', '|', ':', '"', "'", '=', '<', '>'], + '', + $file_name + ); $file_path = './' . $file_name; $folder_path = $this->folder_location . '/' . $this->folder_name; $urlContents = $this->downloadFile($url); @@ -387,6 +402,11 @@ class DownloadPage { // the same as the resource that is needed thus not actually needing to download it foreach($simular_pages as $page) { $resourceName = basename($source); + $resourceName = str_replace( + ['/', '\\', '?', '*', '|', ':', '"', "'", '=', '<', '>'], + '', + $resourceName + ); if (!file_exists($this->folder_location . "/" . $page->WID . "/" . $resourceName)) { continue; } @@ -410,6 +430,11 @@ class DownloadPage { if (!$found_resource) { // Page is unique so there will be no resource that can be cached $resourceName = basename($source); + $resourceName = str_replace( + ['/', '\\', '?', '*', '|', ':', '"', "'", '=', '<', '>'], + '', + $resourceName + ); $link->setAttribute($attribute, './' . $resourceName); $file = fopen($folder_path . '/' . $resourceName, "w"); if ($file){ |
