Skip to content

Commit b04ab76

Browse files
Laszlo Megyerscsibug
authored andcommitted
fix: postgresql tag filtering for odd-length hex-looking values
The tag filtering code misses odd-length strings that contains only hex digits [0-9a-f]. This fix makes the condition for `has_plain_values` the inverse of the condition for `has_hex_values`. Fixes #191
1 parent 39a3a25 commit b04ab76

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/repo/postgres.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,13 +812,13 @@ fn query_from_filter(f: &ReqFilter) -> Option<QueryBuilder<Postgres>> {
812812
.push_bind(key.to_string())
813813
.push(" AND (");
814814

815-
let has_plain_values = val.iter().any(|v| !is_lower_hex(v));
815+
let has_plain_values = val.iter().any(|v| (v.len() % 2 != 0 || !is_lower_hex(v)));
816816
let has_hex_values = val.iter().any(|v| v.len() % 2 == 0 && is_lower_hex(v));
817817
if has_plain_values {
818818
query.push("value in (");
819819
// plain value match first
820820
let mut tag_query = query.separated(", ");
821-
for v in val.iter().filter(|v| !is_lower_hex(v)) {
821+
for v in val.iter().filter(|v| v.len() % 2 != 0 || !is_lower_hex(v)) {
822822
tag_query.push_bind(v.as_bytes());
823823
}
824824
}

0 commit comments

Comments
 (0)