Skip to content

.Net: Add backslash escaping to redis text search values#13902

Merged
westey-m merged 2 commits intomicrosoft:mainfrom
westey-m:redis-backslash-escaping
Apr 21, 2026
Merged

.Net: Add backslash escaping to redis text search values#13902
westey-m merged 2 commits intomicrosoft:mainfrom
westey-m:redis-backslash-escaping

Conversation

@westey-m
Copy link
Copy Markdown
Contributor

Motivation and Context

Description

  • Add backslash escaping to redis text search values

Contribution Checklist

Copilot AI review requested due to automatic review settings April 21, 2026 13:47
@westey-m westey-m requested a review from a team as a code owner April 21, 2026 13:47
@moonbox3 moonbox3 added the .NET Issue or Pull requests regarding .NET code label Apr 21, 2026
@github-actions github-actions Bot changed the title Add backslash escaping to redis text search values .Net: Add backslash escaping to redis text search values Apr 21, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 3 | Confidence: 94% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage


Automated review by westey-m's agents

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional escaping for RedisSearch exact-match/tag query string values so that literal backslashes in user-provided filter values are preserved and can’t be interpreted as escape characters in the query syntax.

Changes:

  • Update SanitizeStringConstant to escape backslashes (\\\) before escaping double quotes.
  • Add unit tests covering backslashes and backslash+quote “injection-style” payloads for ==, Contains, and Any(...Contains...).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dotnet/src/VectorData/Redis/RedisFilterTranslator.cs Escapes backslashes in string constants before generating RedisSearch query fragments.
dotnet/test/VectorData/Redis.UnitTests/RedisFilterTranslatorTests.cs Adds regression tests to validate correct escaping for backslashes in multiple translation paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@westey-m westey-m added this pull request to the merge queue Apr 21, 2026
Merged via the queue into microsoft:main with commit ba37e8e Apr 21, 2026
18 checks passed
@westey-m westey-m deleted the redis-backslash-escaping branch April 21, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants