From a3a563ed41937704e4cebf478d71ca614ea4ac17 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 2 Dec 2023 20:54:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhttp=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=9B=B8=E5=85=B3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpFileManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index 697e554f..5a3217cd 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -584,12 +584,13 @@ static string getFilePath(const Parser &parser,const MediaInfo &media_info, Sess return Parser::parseArgs(str, ";", ","); }); - string url, path; + string url, path, virtual_app; auto it = virtualPathMap.find(media_info.app); if (it != virtualPathMap.end()) { //访问的是virtualPath path = it->second; url = parser.url().substr(1 + media_info.app.size()); + virtual_app = media_info.app + "/"; } else { //访问的是rootPath path = rootPath; @@ -608,7 +609,7 @@ static string getFilePath(const Parser &parser,const MediaInfo &media_info, Sess throw std::runtime_error("Attempting to access files outside of the http root directory"); } // 替换url,防止返回的目录索引网页被注入非法内容 - const_cast(parser).setUrl("/" + ret.substr(http_root.size())); + const_cast(parser).setUrl("/" + virtual_app + ret.substr(http_root.size())); NOTICE_EMIT(BroadcastHttpBeforeAccessArgs, Broadcast::kBroadcastHttpBeforeAccess, parser, ret, sender); return ret; }