swkbd: Fix digit filter

The DIGIT filter was incorrectly implemented as preventing all digits. It actually limits the maximum digit count to max_digits, according to ctrulib and hardware testing.
This commit is contained in:
zhupengfei 2020-02-04 16:56:30 +08:00
parent eb0364dd5f
commit 05a82b15e6
No known key found for this signature in database
GPG key ID: DD129E108BD09378
2 changed files with 5 additions and 6 deletions

View file

@ -15,9 +15,9 @@ namespace Frontend {
ValidationError SoftwareKeyboard::ValidateFilters(const std::string& input) const {
if (config.filters.prevent_digit) {
if (std::any_of(input.begin(), input.end(),
[](unsigned char c) { return std::isdigit(c); })) {
return ValidationError::DigitNotAllowed;
if (std::count_if(input.begin(), input.end(),
[](unsigned char c) { return std::isdigit(c); }) > config.max_digits) {
return ValidationError::MaxDigitsExceeded;
}
}
if (config.filters.prevent_at) {