Sanitize name changer input

This commit is contained in:
Willy-JL
2023-04-23 14:02:55 +01:00
parent 852b051e26
commit ca2884548a
@@ -12,12 +12,28 @@ static void xtreme_app_scene_misc_rename_text_input_callback(void* context) {
view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
}
static bool xtreme_app_scene_misc_rename_validator(const char* text, FuriString* error, void* context) {
UNUSED(context);
for(; *text; ++text) {
const char c = *text;
if((c < '0' || c > '9') && (c < 'A' || c > 'Z') && (c < 'a' || c > 'z')) {
furi_string_printf(error, "Please only\nenter letters\nand numbers!");
return false;
}
}
return true;
}
void xtreme_app_scene_misc_rename_on_enter(void* context) {
XtremeApp* app = context;
TextInput* text_input = app->text_input;
text_input_set_header_text(text_input, "Leave empty for default");
text_input_set_validator(text_input, xtreme_app_scene_misc_rename_validator, NULL);
text_input_set_result_callback(
text_input,
xtreme_app_scene_misc_rename_text_input_callback,