Skip to content

Fix Malformed Preset Filenames - #6615

Closed
ghost wants to merge 2 commits into
develop-ackbarfrom
unknown repository
Closed

Fix Malformed Preset Filenames#6615
ghost wants to merge 2 commits into
develop-ackbarfrom
unknown repository

Conversation

@ghost

@ghost ghost commented May 13, 2026

Copy link
Copy Markdown

This fixes #6586.

Preset names are used directly as filenames without sanitization. Characters like : are illegal in Windows filenames -- on NTFS, : creates an Alternate Data Stream instead of a regular file. A preset called "test :)" bricks the app. The save produces a malformed file, LoadPresets calls nlohmann::json::parse on it with no error handling, and the resulting exception crashes the app on every subsequent launch.

  • New SanitizeFilename function replaces < > : " / \ | ? * and control characters with _, stripping trailing dots and spaces. Applied in both SavePreset and FormatPresetPath (used by delete). The preset's display name in JSON is unchanged -- the user still sees their original name in the UI.
  • std::ofstream doesn't throw on failure -- it fails silently. An is_open() check after opening lets the app log an error and returns instead of writing to a failed stream.
  • Wrapped nlohmann::json::parse in a try-catch so a malformed preset file logs an error and is skipped instead of crashing the app. This also serves to recover any existing installations stuck in a crash loop from previously created bad presets.

Build Artifacts

@ghost ghost changed the title Preset Name Filename Sanitization Fix Malformed Preset Filenames May 15, 2026
}
}

while (!result.empty() && (result.back() == '.' || result.back() == ' ')) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

. strip seems unnecessary, is it only to block . & ..? in that case we can just check for those explicitly in following condition

@ghost ghost closed this by deleting the head repository Jun 9, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant