fix(db-mongodb): failing contains query with special chars (#5776)

This commit is contained in:
Patrik
2024-04-15 10:24:07 -04:00
committed by GitHub
parent dd75fbfee2
commit f3409fab29

View File

@@ -142,7 +142,10 @@ export const sanitizeQueryValue = ({
if (path !== '_id' || (path === '_id' && hasCustomID && field.type === 'text')) {
if (operator === 'contains') {
formattedValue = { $options: 'i', $regex: formattedValue }
formattedValue = {
$options: 'i',
$regex: formattedValue.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'),
}
}
}