-
Notifications
You must be signed in to change notification settings - Fork 407
Support for escaping curly braces in embedded expression #3962
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
base: main
Are you sure you want to change the base?
Conversation
src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpEscapedCharacterSequenceNode.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpRequestParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpRequestParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpRequestParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpRequestParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.Http.Tests/ParserTests.Variables.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.Http.Tests/ParserTests.Variables.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.Http.Tests/ParserTests.Variables.cs
Outdated
Show resolved
Hide resolved
var result = Parse( | ||
""" | ||
|
||
@text=\{{{text\}}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the escaping only intended to work on the RHS of variable assignment? Do we support literal values inside embedded expression within the body of requests for instance, and can those literal values contain {{
sequences that may need to be escaped?
(Sorry drawing a blank on how the embedded expressions are supposed to work within body and whether they only support references to other variables etc. :) If literal values are not supported within embedded expressions and only other variable references are supported there in, then feel free to ignore...)
++generationNumber; | ||
yield return new object[] | ||
{ | ||
new HttpRequestNodeSyntaxSpec(namedRequest, variables, method, url, version, headerSection, bodySection), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to repeat this section?
@@ -355,5 +380,64 @@ with XML.</description> | |||
.Should().BeEquivalentTo("numberValue", "stringValue"); | |||
}); | |||
} | |||
|
|||
private static IEnumerable<HttpVariableDeclarationAndAssignmentNodeSyntaxSpec> ValidVariableDeclarations() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might not be necessary to add so many cases. The goal of these tests is generally not to test every detail of the feature. The unit tests already cover that. They tend to be useful for catching issues with different combinations of syntax (e.g. does the parser move correctly from one node type to another) as well as incomplete syntax (e.g. does the parser handle it gracefully when the user is typing and the syntax is malformed in various normal ways.)
This pull request introduces support for escaped character sequences in HTTP syntax parsing, enabling the handling of complex scenarios such as escaped curly braces within variable values. Key changes include the addition of a new syntax node for escaped characters, updates to parsing logic, and corresponding tests.
Parsing Enhancements:
HttpEscapedCharacterSequenceNode
to represent escaped character sequences in the syntax tree. This node trims escape characters (`This pull request introduces support for escaped character sequences in HTTP syntax parsing, enabling the handling of complex scenarios such as escaped curly braces within variable values. Key changes include the addition of a new syntax node for escaped characters, updates to parsing logic, and corresponding tests.Parsing Enhancements:
) from the text. (
src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpEscapedCharacterSequenceNode.cs
)HttpRequestParser
to detect and parse escaped character sequences using the newParseEscapedCharacterSequence
method. (src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpRequestParser.cs
) [1] [2] [3] [4]Syntax Tree Updates:
HttpVariableValueNode
to support addingHttpEscapedCharacterSequenceNode
as a child node. (src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpVariableValueNode.cs
)HttpRootSyntaxNode
to process escaped character sequences when resolving variable values, ensuring proper handling of escaped braces. (src/Microsoft.DotNet.Interactive.Http.Parsing/Parsing/HttpRootSyntaxNode.cs
)Testing:
src/Microsoft.DotNet.Interactive.Http.Tests/ParserTests.Variables.cs
)