From 17279c264b9fc956f56f09ebad7e8ade96b4985b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 26 Dec 2022 16:23:19 +0900 Subject: [PATCH] Add support for short download URLs #1875 #1922 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Originally committed on April 3, 2022 - Thanks to @misol @conory - getDownloadUrl()에서 기존 메소드 형태 최대한 그대로 유지하는 방향으로 작업 (단, source_filename 파라미터를 전달하지 않으면 긴주소로 강제됨) - getDirectFileUrl()의 불필요하게 복잡한 코드 정리 - getFileList()에서 이미지가 아닌 파일도 절대경로를 반환하도록 수정 - procFileDownload, procFileOutput에서 URL에 포함된 파일명을 검증하도록 하여 동일한 첨부파일에서 파일명 부분만 변형한 링크를 무한 생성할 수 없도록 함 - 짧은주소 미사용시 불필요한 module_srl 파라미터 제거 --- common/framework/Router.php | 6 ++++ .../js/plugins/jquery.fileupload/js/main.js | 8 ++--- modules/file/file.admin.model.php | 2 +- modules/file/file.controller.php | 24 ++++++++++---- modules/file/file.model.php | 32 +++++++++++-------- modules/file/tpl/iframe.html | 2 +- 6 files changed, 49 insertions(+), 25 deletions(-) diff --git a/common/framework/Router.php b/common/framework/Router.php index 8bc39d8ae..b4b0ec1ec 100644 --- a/common/framework/Router.php +++ b/common/framework/Router.php @@ -46,6 +46,12 @@ class Router 'vars' => ['mid' => 'any', 'act' => 'word'], 'priority' => 20, ), + 'files/download/link/$file_srl/$sid/$filename' => array( + 'regexp' => '#^files/download/link/(?[0-9]+)/(?[0-9a-f]+)/(?[^/]+)$#', + 'vars' => ['file_srl' => 'int', 'sid' => 'hex', 'filename' => 'any'], + 'extra_vars' => ['act' => 'procFileDownload'], + 'priority' => 0, + ), 'files/download/$file_srl/$file_key/$filename' => array( 'regexp' => '#^files/download/(?[0-9]+)/(?[a-zA-Z0-9_-]+)/(?[^/]+)$#', 'vars' => ['file_srl' => 'int', 'file_key' => 'any', 'filename' => 'any'], diff --git a/common/js/plugins/jquery.fileupload/js/main.js b/common/js/plugins/jquery.fileupload/js/main.js index 00f3af360..46ab96650 100644 --- a/common/js/plugins/jquery.fileupload/js/main.js +++ b/common/js/plugins/jquery.fileupload/js/main.js @@ -183,8 +183,8 @@ else if(/\.(mp4|webm|ogv)$/i.test(result.source_filename) && opt.autoinsertTypes.video) { if(result.original_type === 'image/gif') { temp_code += '