diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/Parser/CstToAstVisitor.cs b/Microsoft.Azure.Cosmos/src/Query/Core/Parser/CstToAstVisitor.cs index bbaf4c2122..fd92b233a8 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/Parser/CstToAstVisitor.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/Parser/CstToAstVisitor.cs @@ -961,36 +961,35 @@ private static string GetStringValueFromNode(IParseTree parseTree) // https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/constants#remarks // However that's failing in the parser (before reaching this point) and will be fixed separately (after checking server's behavior). StringBuilder stringBuilder = new StringBuilder(text.Length); - for (int i = 1; i < text.Length - 1; i++) + for (int index = 1; index < text.Length - 1; index++) { - switch (text[i]) + switch (text[index]) { case '\\': - if ((i + 1) < (text.Length - 1)) + if ((index + 1) < (text.Length - 1)) { - switch (text[i + 1]) + switch (text[index + 1]) { case '"': case '\\': case '/': - stringBuilder.Append(text[i + 1]); - i++; + stringBuilder.Append(text[index + 1]); + index++; break; default: - stringBuilder.Append(text[i]); + stringBuilder.Append(text[index]); break; } } break; default: - stringBuilder.Append(text[i]); + stringBuilder.Append(text[index]); break; } } - string unescapedString = stringBuilder.ToString(); - return unescapedString; + return stringBuilder.ToString(); } private static Number64 GetNumber64ValueFromNode(IParseTree parseTree) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/BaselineTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/BaselineTests.cs index 6e2162ee2f..419a29229b 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/BaselineTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/BaselineTests.cs @@ -135,8 +135,8 @@ public void ExecuteTestSuite(IEnumerable inputs, [CallerMemberName] stri Assert.IsTrue( matched, - $@" Baseline File {baselinePath}, - Output File {outputPath}, + $@" Baseline File {Path.GetFullPath(baselinePath)}, + Output File {Path.GetFullPath(outputPath)}, Expected: {baselineTextSuffix}, Actual: {outputTextSuffix}"); } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/ScalarExpressionSqlParserBaselineTests.StringLiteral.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/ScalarExpressionSqlParserBaselineTests.StringLiteral.xml index acf037a928..df9e44ceda 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/ScalarExpressionSqlParserBaselineTests.StringLiteral.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/BaselineTest/TestBaseline/ScalarExpressionSqlParserBaselineTests.StringLiteral.xml @@ -17,4 +17,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/Parser/ScalarExpressionSqlParserBaselineTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/Parser/ScalarExpressionSqlParserBaselineTests.cs index 450dc656e0..10f6fe3ee0 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/Parser/ScalarExpressionSqlParserBaselineTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/Parser/ScalarExpressionSqlParserBaselineTests.cs @@ -533,6 +533,12 @@ public void StringLiteral() CreateInput( description: @"Double quoted string literals with escape seqence", scalarExpression: @"[""'SingleQuote"", ""\""DoubleQuote"", ""\\ReverseSolidus"", ""\/solidus"", ""\bBackspace"", ""\fSeparatorFeed"", ""\nLineFeed"", ""\rCarriageReturn"", ""\tTab"", ""\u1234""]"), + CreateInput( + description: @"Single quoted string literals special cases", + scalarExpression: @"['\""', '\""\""', '\\', '\\\\', '\/', '\/\/', '\b', '\b\b', '\f', '\f\f', '\n', '\n\n', '\r', '\r\r', '\t', '\t\t', '\u1234', '\u1234\u1234']"), + CreateInput( + description: @"Double quoted string literals special cases", + scalarExpression: @"[""\"""", ""\""\"""", ""\\"", ""\\\\"", ""\/"", ""\/\/"", ""\b"", ""\b\b"", ""\f"", ""\f\f"", ""\n"", ""\n\n"", ""\r"", ""\r\r"", ""\t"", ""\t\t"", ""\u1234"", ""\u1234\u1234""]"), }; this.ExecuteTestSuite(inputs);