Skip to content

2.296.2 Release notes#2107

Merged
thboop merged 4 commits into
releases/m296from
thboop/hotfix
Sep 8, 2022
Merged

2.296.2 Release notes#2107
thboop merged 4 commits into
releases/m296from
thboop/hotfix

Conversation

@thboop
Copy link
Copy Markdown
Collaborator

@thboop thboop commented Sep 7, 2022

Resolves #2104 and #2103

@thboop thboop requested a review from a team as a code owner September 7, 2022 01:31
// https://docs.microsoft.com/en-us/dotnet/api/system.environment.getcommandlineargs?redirectedfrom=MSDN&view=net-6.0#remarks

// First, find any \ followed by a " and double the number of \ + 1.
value = Regex.Replace(value, @"(\\*)" + "\"", @"$1$1\" + "\"");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NIT: formatting

Copy link
Copy Markdown
Contributor

@fhammerl fhammerl left a comment

Choose a reason for hiding this comment

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

LGTM'

value = Regex.Replace(value, @"(\\*)" + "\"", @"$1$1\" + "\"");
// Next, what if it ends in `\`, it would escape the end quote. So, we need to detect that at the end of the string and perform the same escape
// Luckily, we can just use the $ character with detects the end of string in regex
value = Regex.Replace(value, @"(\\+)$", @"$1$1");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we compile these regexes?

{
public class DockerUtil
{
private static readonly Regex QuoteEscape = new Regex(@"(\\*)" + "\"", RegexOptions.Compiled);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
private static readonly Regex QuoteEscape = new Regex(@"(\\*)" + "\"", RegexOptions.Compiled);
private static readonly Regex QuoteEscape = new Regex(@"(\\*)\"", RegexOptions.Compiled);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can ignore me if the original way was for readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants