mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
fix: DB helper should properly filter entries (#3359)
Previously it was assumed the sed operation was applying the sed expressions as a sequence, but it did not seem to filter entries being looked up correctly. Instead any line that matched either sed expression pattern was output (_value without matching key, values split by the delimiter_), then grep would match any of that causing false-positives. Resolved by piping the first sed expression into the next.
This commit is contained in:
parent
da8d3654b8
commit
1d2df8d499
|
@ -132,11 +132,11 @@ function __db_list_already_contains_value
|
|||
{
|
||||
# Avoids accidentally matching a substring (case-insensitive acceptable):
|
||||
# 1. Extract the current value of the entry (`\1`),
|
||||
# 2. If a value list, split into separate lines (`\n`+`g`) at V_DELIMITER,
|
||||
# 2. Value list support: Split values into separate lines (`\n`+`g`) at V_DELIMITER,
|
||||
# 3. Check each line for an exact match of the target VALUE
|
||||
sed -e "s/^${KEY_LOOKUP}\(.*\)/\1/" \
|
||||
-e "s/${V_DELIMITER}/\n/g" \
|
||||
"${DATABASE}" | grep -qi "^${_VALUE_}$"
|
||||
sed -ne "s/^${KEY_LOOKUP}\+\(.*\)/\1/p" "${DATABASE}" \
|
||||
| sed -e "s/${V_DELIMITER}/\n/g" \
|
||||
| grep -qi "^${_VALUE_}$"
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue