-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Validate short and long names so whitespace or empty names cannot be used #6993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thebentern
merged 7 commits into
meshtastic:master
from
Crank-Git:validate-short-and-long-names
Jun 13, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
414e75d
Say issue #6867 about adding validation for long_name and short_name.…
Crank-Git 952f0aa
Validation for user long_name and short_name implemented. No longer c…
Crank-Git da0e355
Improve whitespace validation for user names with ctype.h, ensure log…
Crank-Git 8ab5ee9
Add whitespace validation to ham mode to prevent validation bypass an…
Crank-Git 73f930d
punctuation change
Crank-Git a797b55
Merge branch 'master' into validate-short-and-long-names
thebentern de73a37
Merge branch 'master' into validate-short-and-long-names
thebentern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "SPILock.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "meshUtils.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <FSCommon.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <ctype.h> // for better whitespace handling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "BleOta.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -155,6 +156,28 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case meshtastic_AdminMessage_set_owner_tag: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG_DEBUG("Client set owner"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Validate names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (*r->set_owner.long_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const char *start = r->set_owner.long_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Skip all whitespace (space, tab, newline, etc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while (*start && isspace((unsigned char)*start)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (*start == '\0') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG_WARN("Rejected long_name: must contain at least 1 non-whitespace character"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (*r->set_owner.short_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const char *start = r->set_owner.short_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while (*start && isspace((unsigned char)*start)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (*start == '\0') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG_WARN("Rejected short_name: must contain at least 1 non-whitespace character"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+160
to
+179
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (*r->set_owner.long_name) { | |
| const char *start = r->set_owner.long_name; | |
| // Skip all whitespace (space, tab, newline, etc) | |
| while (*start && isspace((unsigned char)*start)) | |
| start++; | |
| if (*start == '\0') { | |
| LOG_WARN("Rejected long_name: must contain at least 1 non-whitespace character"); | |
| myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp); | |
| break; | |
| } | |
| } | |
| if (*r->set_owner.short_name) { | |
| const char *start = r->set_owner.short_name; | |
| while (*start && isspace((unsigned char)*start)) | |
| start++; | |
| if (*start == '\0') { | |
| LOG_WARN("Rejected short_name: must contain at least 1 non-whitespace character"); | |
| myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp); | |
| break; | |
| } | |
| const char *start = r->set_owner.long_name; | |
| // Skip all whitespace (space, tab, newline, etc) | |
| while (*start && isspace((unsigned char)*start)) | |
| start++; | |
| if (*start == '\0') { | |
| LOG_WARN("Rejected long_name: must contain at least 1 non-whitespace character"); | |
| myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp); | |
| break; | |
| } | |
| const char *start = r->set_owner.short_name; | |
| while (*start && isspace((unsigned char)*start)) | |
| start++; | |
| if (*start == '\0') { | |
| LOG_WARN("Rejected short_name: must contain at least 1 non-whitespace character"); | |
| myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp); | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.