Sanitize filename before renaming

Fixes #3982
This commit is contained in:
Cohee
2025-05-24 00:02:48 +03:00
parent 1f7c65b45a
commit 8d84871134

View File

@@ -36,7 +36,7 @@ import {
textgenerationwebui_presets,
textgenerationwebui_settings as textgen_settings,
} from './textgen-settings.js';
import { download, equalsIgnoreCaseAndAccents, parseJsonFile, waitUntilCondition } from './utils.js';
import { download, equalsIgnoreCaseAndAccents, getSanitizedFilename, parseJsonFile, waitUntilCondition } from './utils.js';
import { t } from './i18n.js';
import { reasoning_templates } from './reasoning.js';
@@ -891,7 +891,7 @@ export async function initPresetManager() {
const popupHeader = !presetManager.isAdvancedFormatting() ? t`Rename preset` : t`Rename template`;
const oldName = presetManager.getSelectedPresetName();
const newName = await Popup.show.input(popupHeader, t`Enter a new name:`, oldName);
const newName = await getSanitizedFilename(await Popup.show.input(popupHeader, t`Enter a new name:`, oldName) || '');
if (!newName || oldName === newName) {
console.debug(!presetManager.isAdvancedFormatting() ? 'Preset rename cancelled' : 'Template rename cancelled');
return;