Skip to content

Commit 3e230e4

Browse files
committed
Disallow reading files larger than 15MB in notifyOpenTextDocument
1 parent 9f03f6a commit 3e230e4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Core/Sources/Service/Workspace.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,13 @@ extension Workspace {
401401
refreshUpdateTime()
402402
openedFileRecoverableStorage.openFile(fileURL: filespace.fileURL)
403403
Task {
404+
// check if file size is larger than 15MB, if so, return immediately
405+
if let attrs = try? FileManager.default
406+
.attributesOfItem(atPath: filespace.fileURL.path),
407+
let fileSize = attrs[FileAttributeKey.size] as? UInt64,
408+
fileSize > 15 * 1024 * 1024
409+
{ return }
410+
404411
try await suggestionService?.notifyOpenTextDocument(
405412
fileURL: filespace.fileURL,
406413
content: try String(contentsOf: filespace.fileURL, encoding: .utf8)

0 commit comments

Comments
 (0)