Improved handling of file attachments in chats (#689)
Some checks failed
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled

This commit is contained in:
Thorsten Sommer 2026-03-12 12:51:44 +01:00 committed by GitHub
parent c120502215
commit 65ec82cdcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 51 additions and 1 deletions

View File

@ -84,6 +84,9 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi
{ {
var extension = Path.GetExtension(filePath).TrimStart('.').ToLowerInvariant(); var extension = Path.GetExtension(filePath).TrimStart('.').ToLowerInvariant();
if (FileTypeFilter.Executables.FilterExtensions.Contains(extension))
return FileAttachmentType.FORBIDDEN;
// Check if it's an image file: // Check if it's an image file:
if (FileTypeFilter.AllImages.FilterExtensions.Contains(extension)) if (FileTypeFilter.AllImages.FilterExtensions.Contains(extension))
return FileAttachmentType.IMAGE; return FileAttachmentType.IMAGE;
@ -96,7 +99,8 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi
if (FileTypeFilter.PDF.FilterExtensions.Contains(extension) || if (FileTypeFilter.PDF.FilterExtensions.Contains(extension) ||
FileTypeFilter.Text.FilterExtensions.Contains(extension) || FileTypeFilter.Text.FilterExtensions.Contains(extension) ||
FileTypeFilter.AllOffice.FilterExtensions.Contains(extension) || FileTypeFilter.AllOffice.FilterExtensions.Contains(extension) ||
FileTypeFilter.AllSourceCode.FilterExtensions.Contains(extension)) FileTypeFilter.AllSourceCode.FilterExtensions.Contains(extension) ||
FileTypeFilter.IsAllowedSourceLikeFileName(filePath))
return FileAttachmentType.DOCUMENT; return FileAttachmentType.DOCUMENT;
// All other file types are forbidden: // All other file types are forbidden:

View File

@ -12,6 +12,51 @@ namespace AIStudio.Tools.Rust;
public readonly record struct FileTypeFilter(string FilterName, string[] FilterExtensions) public readonly record struct FileTypeFilter(string FilterName, string[] FilterExtensions)
{ {
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(FileTypeFilter).Namespace, nameof(FileTypeFilter)); private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(FileTypeFilter).Namespace, nameof(FileTypeFilter));
private static string[] AllowedSourceLikeFileNames =>
[
"Dockerfile",
"Containerfile",
"Jenkinsfile",
"Makefile",
"GNUmakefile",
"Procfile",
"Vagrantfile",
"Tiltfile",
"Justfile",
"Brewfile",
"Caddyfile",
"Gemfile",
"Podfile",
"Fastfile",
"Appfile",
"Rakefile",
"Dangerfile",
"BUILD",
"WORKSPACE",
"BUCK",
];
private static string[] AllowedSourceLikeFileNamePrefixes =>
[
"Dockerfile",
"Containerfile",
"Jenkinsfile",
"Procfile",
"Caddyfile",
];
public static bool IsAllowedSourceLikeFileName(string filePath)
{
var fileName = Path.GetFileName(filePath);
if (string.IsNullOrWhiteSpace(fileName))
return false;
if (AllowedSourceLikeFileNames.Any(name => string.Equals(name, fileName, StringComparison.OrdinalIgnoreCase)))
return true;
return AllowedSourceLikeFileNamePrefixes.Any(prefix => fileName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase));
}
public static FileTypeFilter PDF => new(TB("PDF Files"), ["pdf"]); public static FileTypeFilter PDF => new(TB("PDF Files"), ["pdf"]);

View File

@ -7,5 +7,6 @@
- Improved the user-language logging by limiting language detection logs to a single entry per app start. - Improved the user-language logging by limiting language detection logs to a single entry per app start.
- Improved the logbook readability by removing non-readable special characters from log entries. - Improved the logbook readability by removing non-readable special characters from log entries.
- Improved the logbook reliability by significantly reducing duplicate log entries. - Improved the logbook reliability by significantly reducing duplicate log entries.
- Improved file attachments in chats: configuration and project files such as `Dockerfile`, `Caddyfile`, `Makefile`, or `Jenkinsfile` are now included more reliably when you send them to the AI.
- Improved the validation of additional API parameters in the advanced provider settings to help catch formatting mistakes earlier. - Improved the validation of additional API parameters in the advanced provider settings to help catch formatting mistakes earlier.
- Fixed an issue where the app could turn white or appear invisible in certain chats after HTML-like content was shown. Thanks Inga for reporting this issue and providing some context on how to reproduce it. - Fixed an issue where the app could turn white or appear invisible in certain chats after HTML-like content was shown. Thanks Inga for reporting this issue and providing some context on how to reproduce it.