mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-19 09:19:05 +02:00
Restrict username minimum length too (3 chars)
This commit is contained in:
1 parent
77e575dd65
commit
6ebbb434e4
7 files changed
+19
-9
No files matched your search
@@ -105,7 +105,7 @@ int countChar(std::string_view haystack, char needle) {
|
||||
return count;
|
||||
}
|
||||
|
||||
std::string SanitizeString(std::string_view input, StringRestriction restriction, int maxLength) {
|
||||
std::string SanitizeString(std::string_view input, StringRestriction restriction, int minLength, int maxLength) {
|
||||
if (restriction == StringRestriction::None) {
|
||||
return std::string(input);
|
||||
}
|
||||
@@ -127,6 +127,14 @@ std::string SanitizeString(std::string_view input, StringRestriction restriction
|
||||
}
|
||||
}
|
||||
|
||||
if (minLength >= 0) {
|
||||
if (sanitized.size() < minLength) {
|
||||
// Just reject it by returning an empty string, as we can't really
|
||||
// conjure up new characters here.
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
if (maxLength >= 0) {
|
||||
// TODO: Cut at whole UTF-8 chars!
|
||||
if (sanitized.size() > maxLength) {
|
||||
|
||||
Reference in new issue
Block a user