This commit is contained in:
J-Jamet
2025-07-01 17:22:42 +02:00
parent c79144400f
commit f31a30bf47
7 changed files with 38 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
KeePassDX(4.1.2)
* Fix URL matching in presence of a path #1940
* Fix URL matching in presence of a path #1940 #1946 #2003
KeePassDX(4.1.1)
* Fix date parser #1933

View File

@@ -60,6 +60,7 @@ object SearchHelper {
// If search provide results
database.createVirtualGroupFromSearchInfo(
searchInfo.toString(),
searchInfo.isASearchByDomain(),
MAX_SEARCH_ENTRY
)?.let { searchGroup ->
if (searchGroup.numberOfChildEntries > 0) {

View File

@@ -31,6 +31,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
private var searchUsername: CompoundButton
private var searchPassword: CompoundButton
private var searchURL: CompoundButton
private var searchByURLDomain: Boolean = false
private var searchExpired: CompoundButton
private var searchNotes: CompoundButton
private var searchOther: CompoundButton
@@ -50,6 +51,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
this.searchInUsernames = searchUsername.isChecked
this.searchInPasswords = searchPassword.isChecked
this.searchInUrls = searchURL.isChecked
this.searchByDomain = searchByURLDomain
this.searchInExpired = searchExpired.isChecked
this.searchInNotes = searchNotes.isChecked
this.searchInOther = searchOther.isChecked
@@ -70,6 +72,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
searchUsername.isChecked = value.searchInUsernames
searchPassword.isChecked = value.searchInPasswords
searchURL.isChecked = value.searchInUrls
searchByURLDomain = value.searchByDomain
searchExpired.isChecked = value.searchInExpired
searchNotes.isChecked = value.searchInNotes
searchOther.isChecked = value.searchInOther

View File

@@ -38,7 +38,12 @@ import com.kunzisoft.keepass.database.element.node.NodeIdInt
import com.kunzisoft.keepass.database.element.node.NodeIdUUID
import com.kunzisoft.keepass.database.element.template.Template
import com.kunzisoft.keepass.database.element.template.TemplateEngine
import com.kunzisoft.keepass.database.exception.*
import com.kunzisoft.keepass.database.exception.DatabaseException
import com.kunzisoft.keepass.database.exception.DatabaseInputException
import com.kunzisoft.keepass.database.exception.DatabaseOutputException
import com.kunzisoft.keepass.database.exception.FileNotFoundDatabaseException
import com.kunzisoft.keepass.database.exception.MergeDatabaseKDBException
import com.kunzisoft.keepass.database.exception.SignatureDatabaseException
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDB
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX.Companion.FILE_VERSION_40
@@ -51,11 +56,17 @@ import com.kunzisoft.keepass.database.search.SearchHelper
import com.kunzisoft.keepass.database.search.SearchParameters
import com.kunzisoft.keepass.hardware.HardwareKey
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
import com.kunzisoft.keepass.utils.*
import com.kunzisoft.keepass.utils.SingletonHolder
import com.kunzisoft.keepass.utils.StringUtil.toFormattedColorInt
import com.kunzisoft.keepass.utils.StringUtil.toFormattedColorString
import java.io.*
import java.util.*
import com.kunzisoft.keepass.utils.readAllBytes
import com.kunzisoft.keepass.utils.readBytes4ToUInt
import java.io.BufferedInputStream
import java.io.File
import java.io.FileNotFoundException
import java.io.InputStream
import java.io.OutputStream
import java.util.UUID
open class Database {
@@ -875,6 +886,7 @@ open class Database {
fun createVirtualGroupFromSearchInfo(
searchInfoString: String,
searchInfoByDomain: Boolean,
max: Int = Integer.MAX_VALUE
): Group? {
return mSearchHelper.createVirtualGroupWithSearchResult(this,
@@ -884,6 +896,7 @@ open class Database {
searchInUsernames = false
searchInPasswords = false
searchInUrls = true
searchByDomain = searchInfoByDomain
searchInNotes = true
searchInOTP = false
searchInOther = true

View File

@@ -150,11 +150,13 @@ class SearchHelper {
}
if (searchParameters.searchInUrls) {
if (checkSearchQuery(entry.url, searchParameters) { stringToCheck, word ->
try {
stringToCheck.inTheSameDomainAs(word, sameSubDomain = true)
} catch (e: Exception) {
false
}
if (searchParameters.searchByDomain) {
try {
stringToCheck.inTheSameDomainAs(word, sameSubDomain = true)
} catch (e: Exception) {
false
}
} else null
})
return true
}
@@ -186,7 +188,7 @@ class SearchHelper {
private fun checkSearchQuery(
stringToCheck: String,
searchParameters: SearchParameters,
specialComparison: ((check: String, word: String) -> Boolean)? = null): Boolean {
specialComparison: ((check: String, word: String) -> Boolean?)? = null): Boolean {
/*
// TODO Search settings
var removeAccents = true <- Too much time, to study
@@ -203,13 +205,10 @@ class SearchHelper {
}
regex.matches(stringToCheck)
} else {
var searchFound = true
searchParameters.searchQuery.split(" ").forEach { word ->
searchFound = searchFound
&& (specialComparison?.invoke(stringToCheck, word)
?: stringToCheck.contains(word, !searchParameters.caseSensitive))
searchParameters.searchQuery.split(" ").any { word ->
specialComparison?.invoke(stringToCheck, word)
?: stringToCheck.contains(word, !searchParameters.caseSensitive)
}
searchFound
}
}
}

View File

@@ -45,6 +45,7 @@ class SearchParameters() : Parcelable{
var searchInSearchableGroup = true
var searchInRecycleBin = false
var searchInTemplates = false
var searchByDomain = false
constructor(parcel: Parcel) : this() {
searchQuery = parcel.readString() ?: searchQuery

View File

@@ -85,6 +85,10 @@ class SearchInfo : ObjectNameResource, Parcelable {
&& otpString == null
}
fun isASearchByDomain(): Boolean {
return toString() == webDomain && webDomain != null
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is SearchInfo) return false