From e94a9305b62f1983aaa57e2daf9db1aff65fb4a7 Mon Sep 17 00:00:00 2001 From: Edoardo Lolletti Date: Thu, 21 Nov 2024 22:59:04 +0100 Subject: [PATCH] Replace any non alphanumerical character with '_' for output filenames (#246) Fixes dumping carts with headers that have random garbage data in their gameTitle that are not actually ascii characters, thus making the dump fail because the output file cannot be opened --- arm9/source/dumpOperations.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/arm9/source/dumpOperations.cpp b/arm9/source/dumpOperations.cpp index a517639..f2f944f 100644 --- a/arm9/source/dumpOperations.cpp +++ b/arm9/source/dumpOperations.cpp @@ -16,6 +16,7 @@ #include "screenshot.h" #include "version.h" +#include #include #include #include @@ -825,18 +826,8 @@ void ndsCardDump(void) { sprintf(gameTitle, "NO-TITLE"); } else { for(uint i = 0; i < sizeof(gameTitle); i++) { - switch(gameTitle[i]) { - case '>': - case '<': - case ':': - case '"': - case '/': - case '\x5C': - case '|': - case '?': - case '*': - gameTitle[i] = '_'; - } + if(!isalnum(gameTitle[i])) + gameTitle[i] = '_'; } } if (gameCode[0] == 0 || gameCode[0] == 0x23 || gameCode[0] == 0xFF) {