mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix search with non-latin chars #971
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
KeePassDX(3.0.0)
|
||||
*
|
||||
* Fix search with non-latin chars #971
|
||||
|
||||
KeePassDX(2.9.19)
|
||||
* Fix search slowdown #964
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.kunzisoft.keepass.model.SearchInfo
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields.OTP_FIELD
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.StringUtil.flattenToAscii
|
||||
import com.kunzisoft.keepass.utils.StringUtil.removeAccents
|
||||
import com.kunzisoft.keepass.utils.UuidUtil
|
||||
|
||||
class SearchHelper {
|
||||
@@ -177,13 +177,13 @@ class SearchHelper {
|
||||
// TODO Search settings
|
||||
var regularExpression = false
|
||||
var ignoreCase = true
|
||||
var flattenToASCII = true
|
||||
var removeAccents = true
|
||||
var excludeExpired = false
|
||||
var searchOnlyInCurrentGroup = false
|
||||
*/
|
||||
return stringToCheck.isNotEmpty()
|
||||
&& stringToCheck.flattenToAscii().contains(
|
||||
searchParameters.searchQuery.flattenToAscii(), true)
|
||||
&& stringToCheck.removeAccents().contains(
|
||||
searchParameters.searchQuery.removeAccents(), true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,19 +12,9 @@ object StringUtil {
|
||||
return this.replace("[\\r|\\n|\\t|\\s|\\u00A0]+".toRegex(), "")
|
||||
}
|
||||
|
||||
fun String.flattenToAscii(): String {
|
||||
var string = this
|
||||
val out = CharArray(string.length)
|
||||
string = Normalizer.normalize(string, Normalizer.Form.NFD)
|
||||
var j = 0
|
||||
var i = 0
|
||||
val n = string.length
|
||||
while (i < n) {
|
||||
val c = string[i]
|
||||
if (c <= '\u007F') out[j++] = c
|
||||
++i
|
||||
}
|
||||
return String(out)
|
||||
fun String.removeAccents(): String {
|
||||
return Normalizer.normalize(this, Normalizer.Form.NFD)
|
||||
.replace("\\p{Mn}+".toRegex(), "")
|
||||
}
|
||||
|
||||
fun ByteArray.toHexString() = joinToString("") { "%02X".format(it) }
|
||||
|
||||
@@ -1 +1 @@
|
||||
*
|
||||
* Fix search with non-latin chars #971
|
||||
@@ -1 +1 @@
|
||||
*
|
||||
* Correction de la recherche avec des caractères non latin #971
|
||||
Reference in New Issue
Block a user