Show warning for control/whitespace chars in passwords

This commit is contained in:
M66B
2020-01-08 13:21:53 +01:00
parent b696b637e7
commit 4fa7c48d2b
10 changed files with 184 additions and 4 deletions

View File

@@ -584,6 +584,26 @@ public class Helper {
return result.toArray(new String[0]);
}
static boolean containsWhiteSpace(String text) {
return text.matches(".*\\s+.*");
}
static boolean containsControlChars(String text) {
for (int offset = 0; offset < text.length(); ) {
int codePoint = text.codePointAt(offset);
offset += Character.charCount(codePoint);
switch (Character.getType(codePoint)) {
case Character.CONTROL: // \p{Cc}
case Character.FORMAT: // \p{Cf}
case Character.PRIVATE_USE: // \p{Co}
case Character.SURROGATE: // \p{Cs}
case Character.UNASSIGNED: // \p{Cn}
return true;
}
}
return false;
}
// Files
static String sanitizeFilename(String name) {