Skip to content

Commit

Permalink
consider dot as literal when in brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsdennis committed May 13, 2024
1 parent 6a2b894 commit 172dc8e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion JsonPath/UtilityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ public static string HandleDotNetSupportIssues(this string regex)
{
var sb = new StringBuilder();
var escaped = false;
var inBrackets = false;
foreach (var c in regex)
{
if (!escaped && c == '.')
if (!escaped && !inBrackets && c == '.')
{
// The Regex class doesn't match `.` on non-BMP unicode very well,
// so we need to translate that to something it does understand.
Expand All @@ -91,6 +92,17 @@ public static string HandleDotNetSupportIssues(this string regex)
escaped = true;
continue;
}
if (!escaped && c == '[')
{
inBrackets = true;
continue;
}

if (!escaped && c == ']')
{
inBrackets = false;
continue;
}
}

escaped = false;
Expand Down

0 comments on commit 172dc8e

Please sign in to comment.