mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-23 06:17:59 +00:00
fix: correctly escape backslash in queries (#10522)
# Which Problems Are Solved While investigating a support ticket, it was discovered that some queries using equals or not equals without case matching were not correctly escaping the value to compare. If a value contained a backslash (`\`) the row would not match. # How the Problems Are Solved - Fixed the escaping for backslash for `like` operations. - Changed equals and not equals comparison without case matching to `=` instead of `like`. # Additional Changes None # Additional Context - related to a support request - requires backport to v.3 and v4.x
This commit is contained in:
@@ -288,9 +288,7 @@ func NewTextQuery(col Column, value string, compare TextComparison) (*textQuery,
|
||||
}
|
||||
// handle the comparisons which use (i)like and therefore need to escape potential wildcards in the value
|
||||
switch compare {
|
||||
case TextEqualsIgnoreCase,
|
||||
TextNotEqualsIgnoreCase,
|
||||
TextStartsWith,
|
||||
case TextStartsWith,
|
||||
TextStartsWithIgnoreCase,
|
||||
TextEndsWith,
|
||||
TextEndsWithIgnoreCase,
|
||||
@@ -300,6 +298,8 @@ func NewTextQuery(col Column, value string, compare TextComparison) (*textQuery,
|
||||
case TextEquals,
|
||||
TextListContains,
|
||||
TextNotEquals,
|
||||
TextEqualsIgnoreCase,
|
||||
TextNotEqualsIgnoreCase,
|
||||
textCompareMax:
|
||||
// do nothing
|
||||
}
|
||||
@@ -335,9 +335,9 @@ func (q *textQuery) comp() sq.Sqlizer {
|
||||
case TextNotEquals:
|
||||
return sq.NotEq{q.Column.identifier(): q.Text}
|
||||
case TextEqualsIgnoreCase:
|
||||
return sq.Like{"LOWER(" + q.Column.identifier() + ")": strings.ToLower(q.Text)}
|
||||
return sq.Eq{"LOWER(" + q.Column.identifier() + ")": strings.ToLower(q.Text)}
|
||||
case TextNotEqualsIgnoreCase:
|
||||
return sq.NotLike{"LOWER(" + q.Column.identifier() + ")": strings.ToLower(q.Text)}
|
||||
return sq.NotEq{"LOWER(" + q.Column.identifier() + ")": strings.ToLower(q.Text)}
|
||||
case TextStartsWith:
|
||||
return sq.Like{q.Column.identifier(): q.Text + "%"}
|
||||
case TextStartsWithIgnoreCase:
|
||||
|
Reference in New Issue
Block a user