Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ private static string EscapeImpl(ReadOnlySpan<char> input, int indexOfMetachar)
case '\f':
ch = 'f';
break;
case '\v':
ch = 'v';
break;
}

vsb.Append('\\');
Expand Down Expand Up @@ -1602,7 +1605,7 @@ private char ScanCharEscape()
case 't':
return '\t';
case 'v':
return '\u000B';
return '\v';
case 'c':
return ScanControl();
default:
Expand Down Expand Up @@ -1923,7 +1926,7 @@ internal static int MapCaptureNumber(int capnum, Hashtable? caps) =>
private const byte Q = 4; // quantifier * + ? {
private const byte S = 3; // stopper $ ( ) . [ \ ^ |
private const byte Z = 2; // # stopper #
private const byte W = 1; // whitespace \t \n \f \r ' '
private const byte W = 1; // whitespace \t \n \v \f \r ' '

/// <summary>For categorizing ASCII characters.</summary>
private static ReadOnlySpan<byte> Category =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ public static void Escape(string str, string expected)
}
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNetCore))]
[InlineData("\v", "\\v")]
[InlineData("\n\r\v\t\f", "\\n\\r\\v\\t\\f")]
public static void Escape_VerticalTab(string str, string expected)
{
Assert.Equal(expected, Regex.Escape(str));

if (expected.Length > 0)
{
const int Count = 100;
Assert.Equal(string.Concat(Enumerable.Repeat(expected, Count)), Regex.Escape(string.Concat(Enumerable.Repeat(str, Count))));
}
}

[Fact]
public void Escape_NullString_ThrowsArgumentNullException()
{
Expand All @@ -49,6 +63,20 @@ public void Unescape(string str, string expected)
}
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNetCore))]
[InlineData("\\v", "\v")]
[InlineData("\\n\\r\\v\\t\\f", "\n\r\v\t\f")]
public void Unescape_VerticalTab(string str, string expected)
{
Assert.Equal(expected, Regex.Unescape(str));

if (expected.Length > 0)
{
const int Count = 100;
Assert.Equal(string.Concat(Enumerable.Repeat(expected, Count)), Regex.Unescape(string.Concat(Enumerable.Repeat(str, Count))));
}
}

[Fact]
public void Unscape_NullString_ThrowsArgumentNullException()
{
Expand Down