From ee38124db7bebfd37f61105a9b91a1b11645c51a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 26 Aug 2022 17:33:01 +0800 Subject: [PATCH] Optimize symbolic links checking --- src/webui/webapplication.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index 9bbd4df90..2bcd21a6c 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -157,8 +157,10 @@ void WebApplication::sendWebUIFile() if (!Utils::Fs::isRegularFile(localPath)) throw InternalServerErrorHTTPError(tr("Unacceptable file type, only regular file is allowed.")); - QFileInfo fileInfo {localPath.data()}; - while (Path(fileInfo.filePath()) != m_rootFolder) + const QString rootFolder = m_rootFolder.data(); + + QFileInfo fileInfo {localPath.parentPath().data()}; + while (fileInfo.path() != rootFolder) { if (fileInfo.isSymLink()) throw InternalServerErrorHTTPError(tr("Symlinks inside alternative UI folder are forbidden."));