try fix #% in file name

pull/240/head
qkqpttgf 2021-03-07 23:07:54 +08:00 committed by GitHub
parent d42547bdfb
commit 2aec731ab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -692,6 +692,7 @@ function comppass($pass)
function encode_str_replace($str) function encode_str_replace($str)
{ {
$str = str_replace('%','%25',$str);
$str = str_replace('&','&',$str); $str = str_replace('&','&',$str);
$str = str_replace('+','%2B',$str); $str = str_replace('+','%2B',$str);
$str = str_replace('#','%23',$str); $str = str_replace('#','%23',$str);
@ -2037,7 +2038,8 @@ function render_list($path = '', $files = [])
if ($_SERVER['admin'] or !isHideFile($file['name'])) { if ($_SERVER['admin'] or !isHideFile($file['name'])) {
$filenum++; $filenum++;
$ext = strtolower(substr($file['name'], strrpos($file['name'], '.') + 1)); $ext = strtolower(substr($file['name'], strrpos($file['name'], '.') + 1));
$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . encode_str_replace($file['name'])), $FolderList); $FolderListStr = $FolderList;
while (strpos($FolderListStr, '<!--FileEncodeReplaceUrl-->')) $FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . encode_str_replace($file['name'])), $FolderListStr);
$FolderListStr = str_replace('<!--FileExt-->', $ext, $FolderListStr); $FolderListStr = str_replace('<!--FileExt-->', $ext, $FolderListStr);
if (in_array($ext, $exts['music'])) $FolderListStr = str_replace('<!--FileExtType-->', 'audio', $FolderListStr); if (in_array($ext, $exts['music'])) $FolderListStr = str_replace('<!--FileExtType-->', 'audio', $FolderListStr);
elseif (in_array($ext, $exts['video'])) $FolderListStr = str_replace('<!--FileExtType-->', 'iframe', $FolderListStr); elseif (in_array($ext, $exts['video'])) $FolderListStr = str_replace('<!--FileExtType-->', 'iframe', $FolderListStr);