fix: Special Characters #2180

This commit is contained in:
J-Jamet
2025-10-07 13:56:27 +02:00
parent 90b3b56893
commit 05336e93a0
6 changed files with 37 additions and 33 deletions

View File

@@ -6,7 +6,7 @@ KeePassDX(4.2.0)
* Change Passkey Backup Eligibility & Backup State #2135 #2150
* Search settings #2112 #2181 #2187
* Autofill refactoring #765
* Small fixes #2157 #2164 #2171 #2122
* Small fixes #2157 #2164 #2171 #2122 #2180
KeePassDX(4.1.9)
* Fix landscape UI #2198 #2200 (@chenxiaolong)

View File

@@ -293,20 +293,22 @@ class PasswordGeneratorFragment : DatabaseFragment() {
private fun generatePassword() {
var password = ""
try {
password = PasswordGenerator(resources).generatePassword(getPasswordLength(),
uppercaseCompound.isChecked,
lowercaseCompound.isChecked,
digitsCompound.isChecked,
minusCompound.isChecked,
underlineCompound.isChecked,
spaceCompound.isChecked,
specialsCompound.isChecked,
bracketsCompound.isChecked,
extendedCompound.isChecked,
getConsiderChars(),
getIgnoreChars(),
atLeastOneCompound.isChecked,
excludeAmbiguousCompound.isChecked)
password = PasswordGenerator(resources).generatePassword(
length = getPasswordLength(),
upperCase = uppercaseCompound.isChecked,
lowerCase = lowercaseCompound.isChecked,
digits = digitsCompound.isChecked,
minus = minusCompound.isChecked,
underline = underlineCompound.isChecked,
space = spaceCompound.isChecked,
specials = specialsCompound.isChecked,
brackets = bracketsCompound.isChecked,
extended = extendedCompound.isChecked,
considerChars = getConsiderChars(),
ignoreChars = getIgnoreChars(),
atLeastOneFromEach = atLeastOneCompound.isChecked,
excludeAmbiguousChar = excludeAmbiguousCompound.isChecked
)
} catch (e: Exception) {
Log.e(TAG, "Unable to generate a password", e)
}

View File

@@ -33,20 +33,22 @@ import java.util.*
class PasswordGenerator(private val resources: Resources) {
@Throws(IllegalArgumentException::class)
fun generatePassword(length: Int,
upperCase: Boolean,
lowerCase: Boolean,
digits: Boolean,
minus: Boolean,
underline: Boolean,
space: Boolean,
specials: Boolean,
brackets: Boolean,
extended: Boolean,
considerChars: String,
ignoreChars: String,
atLeastOneFromEach: Boolean,
excludeAmbiguousChar: Boolean): String {
fun generatePassword(
length: Int,
upperCase: Boolean,
lowerCase: Boolean,
digits: Boolean,
minus: Boolean,
underline: Boolean,
space: Boolean,
specials: Boolean,
brackets: Boolean,
extended: Boolean,
considerChars: String,
ignoreChars: String,
atLeastOneFromEach: Boolean,
excludeAmbiguousChar: Boolean
): String {
// Desired password length is 0 or less
if (length <= 0) {
throw IllegalArgumentException(resources.getString(R.string.error_wrong_length))
@@ -228,7 +230,7 @@ class PasswordGenerator(private val resources: Resources) {
private const val MINUS_CHAR = "-"
private const val UNDERLINE_CHAR = "_"
private const val SPACE_CHAR = " "
private const val SPECIAL_CHARS = "!\"#$%&'*+,./:;=?@\\^`"
private const val SPECIAL_CHARS = "&/,^@.#:%\\='$!?*`;+\"|~"
private const val BRACKET_CHARS = "[]{}()<>"
private const val AMBIGUOUS_CHARS = "iI|lLoO01"

View File

@@ -462,7 +462,7 @@
<string name="visual_minus" translatable="false">-</string>
<string name="visual_underline" translatable="false">_</string>
<string name="visual_space" translatable="false"> </string>
<string name="visual_special" translatable="false">&amp;\/,^@.#&quot;:%\\='$!*`;+</string>
<string name="visual_special" translatable="false">&amp;\/,^@.#&quot;:%\\='$!?*`;+\"|~</string>
<string name="visual_brackets" translatable="false">[](){}&lt;&gt;</string>
<string name="visual_extended" translatable="false">ñæËÌÂÝÜ...</string>
<string-array name="list_password_generator_options_default_values">

View File

@@ -3,4 +3,4 @@
* Setting to close database after a Passkey selection #2187
* Warning when overwriting existing Passkey #2124
* Autofill refactoring #765
* Small fixes #2171 #2150 #2159 #2122
* Small fixes #2171 #2150 #2159 #2122 #2180

View File

@@ -3,4 +3,4 @@
* Paramètre de fermeture de la base après une sélection de Passkey #2187
* Mise en garde lors de l'écrasement d'un Passkey existant #21124
* Refonte du remplissage automatique #765
* Petites corrections #2171 #2150 #2159 #2122
* Petites corrections #2171 #2150 #2159 #2122 #2180