-
-
Notifications
You must be signed in to change notification settings - Fork 244
Closed
Labels
Description
In issue #65 some issues regarding the usage of escaped strings have been fixed. I am currently facing another issue in combination with escaped characters (backslashes and quotation marks).
TextParser.cs seems to not handle those scenarios correctly.
I have been able to reproduce the issue in unit tests:
[Fact]
public void ParseLambda_StringLiteral_Backslash()
{
string expectedLeftValue = "Property1.IndexOf(\"\\\")";
string expectedRightValue = "0";
var expression = DynamicExpressionParser.ParseLambda(
new[] { Expression.Parameter(typeof(string), "Property1") },
typeof(Boolean),
string.Format("{0} >= {1}", expectedLeftValue, expectedRightValue));
string leftValue = ((BinaryExpression)expression.Body).Left.ToString();
string rightValue = ((BinaryExpression)expression.Body).Right.ToString();
Assert.Equal(typeof(Boolean), expression.Body.Type);
Assert.Equal(expectedLeftValue, leftValue);
Assert.Equal(expectedRightValue, rightValue);
}
[Fact]
public void ParseLambda_StringLiteral_QuotationMark()
{
string expectedLeftValue = "Property1.IndexOf(\"\\\"\")";
string expectedRightValue = "0";
var expression = DynamicExpressionParser.ParseLambda(
new[] { Expression.Parameter(typeof(string), "Property1") },
typeof(Boolean),
string.Format("{0} >= {1}", expectedLeftValue, expectedRightValue));
string leftValue = ((BinaryExpression)expression.Body).Left.ToString();
string rightValue = ((BinaryExpression)expression.Body).Right.ToString();
Assert.Equal(typeof(Boolean), expression.Body.Type);
Assert.Equal(expectedLeftValue, leftValue);
Assert.Equal(expectedRightValue, rightValue);
}I think the issue is that the current implementation assumes that it is always a full string (starting and ending with an escaped quotation mark) and not only a single escaped character.
Edit: Updated unit tests code
Reactions are currently unavailable