-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser interpreting the two consecutive escape sequences \"\" as a single escape sequence #786
Comments
BTW I'm using |
@brettwinters From: https://www.myget.org/F/system-linq-dynamic-core/api/v3/index.json |
Hi @StefH - I'm having some trouble using myget. Sorry about this but would you mind publishing to nuget? otherwise please could you point me to a online c# ide so I can write some tests? |
This page describes how to use myget: |
@brettwinters I did introduce a new config enum like below to make sure that this solution is now the default, but if users want to use the old parsing, they can configure it. Do you think it's a good naming? namespace System.Linq.Dynamic.Core.Config;
/// <summary>
/// Defines the types of string literal parsing that can be performed.
/// </summary>
public enum StringLiteralParsingType : byte
{
/// <summary>
/// Represents the default string literal parsing type. Double quotes should be escaped using the default escaping.
/// E.G. var expression = "StaticHelper.Filter(\"UserName == \\\"x\\\"\")";
///
/// [Default]
/// </summary>
Default = 0,
/// <summary>
/// Represents a string literal parsing type where a double quotes should be escaped by two double quotes.
/// E.G. var expression = "StaticHelper.Filter(\"UserName == "\"\"x\"\"\")";
/// </summary>
EscapeDoubleQuoteByTwoDoubleQuotes = 1
} |
Hi @StefH - escaping and unescaping serialised strings get really confusing quickly haha The rule I think is that each pair of backslashes So But the |
wait I just confused myself. You're right |
The parser cannot handle both cases automatically. You need to use the config. (I did not notice the error in the example, I will verify it..) |
Don't ask me why I'm doing this (but the output needs to be escaped json) but when I do the following:
The parser outputs:
"{\"PropertyA\":\"}"
vs"{\"PropertyA\":\"\"}"
expectedThe only thing that seems to work is if the string is as follows
"\"{\\\\\\\"PropertyA\\\\\\\":\\\\\\\"\\\\\\\"}\""
Note: Parsing
"\"{\\\"PropertyA\\\":\\\"abc\\\"}\""
and"\"{\\\"PropertyA\\\":\\\" \\\"}\""
(space) works correctlyThe text was updated successfully, but these errors were encountered: