Matugen: improved wallpaper filepath escaping to ensure it works well with potential non standard characters.

This commit is contained in:
ItsLemmy
2025-11-29 18:01:33 -05:00
parent 5451985e48
commit 017a5a6f91

View File

@@ -176,10 +176,13 @@ Singleton {
function buildMatugenScript(content, wallpaper, mode) {
const delimiter = "MATUGEN_CONFIG_EOF_" + Math.random().toString(36).substr(2, 9);
const pathEsc = dynamicConfigPath.replace(/'/g, "'\\''");
const wpDelimiter = "WALLPAPER_PATH_EOF_" + Math.random().toString(36).substr(2, 9);
// Use heredoc for wallpaper path to avoid all escaping issues
let script = `cat > '${pathEsc}' << '${delimiter}'\n${content}\n${delimiter}\n`;
script += `matugen image '${wallpaper}' --config '${pathEsc}' --mode ${mode} --type ${Settings.data.colorSchemes.matugenSchemeType}`;
script += buildUserTemplateCommand(wallpaper, mode);
script += `NOCTALIA_WP_PATH=$(cat << '${wpDelimiter}'\n${wallpaper}\n${wpDelimiter}\n)\n`;
script += `matugen image "$NOCTALIA_WP_PATH" --config '${pathEsc}' --mode ${mode} --type ${Settings.data.colorSchemes.matugenSchemeType}`;
script += buildUserTemplateCommand("$NOCTALIA_WP_PATH", mode);
return script + "\n";
}