mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-06-27 19:16:27 +00:00
Added explicit validation for '..' path segments
This commit is contained in:
parent
8cc24a27f7
commit
0fc78939b7
@ -220,6 +220,13 @@ public record ChatTemplate(
|
|||||||
var relativePath = filePath
|
var relativePath = filePath
|
||||||
.Replace('/', Path.DirectorySeparatorChar)
|
.Replace('/', Path.DirectorySeparatorChar)
|
||||||
.Replace('\\', Path.DirectorySeparatorChar);
|
.Replace('\\', Path.DirectorySeparatorChar);
|
||||||
|
|
||||||
|
if (relativePath.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries).Any(segment => segment == ".."))
|
||||||
|
{
|
||||||
|
LOGGER.LogWarning("The relative FileAttachments entry {AttachmentNum} in chat template {IdxChatTemplate} contains '..' path segments and will be ignored.", attachmentNum, idx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var combinedPath = Path.GetFullPath(Path.Combine(pluginRoot, relativePath));
|
var combinedPath = Path.GetFullPath(Path.Combine(pluginRoot, relativePath));
|
||||||
var pluginRootWithSeparator = pluginRoot.EndsWith(Path.DirectorySeparatorChar)
|
var pluginRootWithSeparator = pluginRoot.EndsWith(Path.DirectorySeparatorChar)
|
||||||
? pluginRoot
|
? pluginRoot
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user