@@ -1797,7 +1797,7 @@ private static bool CheckForColonInFirstPathSegment(string uriString)
1797
1797
1798
1798
internal static string InternalEscapeString ( string rawString ) =>
1799
1799
rawString is null ? string . Empty :
1800
- UriHelper . EscapeString ( rawString , checkExistingEscaped : true , UriHelper . UnreservedReservedTable , '?' , '#' ) ;
1800
+ UriHelper . EscapeString ( rawString , checkExistingEscaped : true , UriHelper . UnreservedReservedExceptQuestionMarkHash ) ;
1801
1801
1802
1802
//
1803
1803
// This method is called first to figure out the scheme or a simple file path
@@ -2359,7 +2359,7 @@ private unsafe void CreateHostString()
2359
2359
flags |= Flags . E_HostNotCanonical ;
2360
2360
if ( NotAny ( Flags . UserEscaped ) )
2361
2361
{
2362
- host = UriHelper . EscapeString ( host , checkExistingEscaped : ! IsImplicitFile , UriHelper . UnreservedReservedTable , '?' , '#' ) ;
2362
+ host = UriHelper . EscapeString ( host , checkExistingEscaped : ! IsImplicitFile , UriHelper . UnreservedReservedExceptQuestionMarkHash ) ;
2363
2363
}
2364
2364
else
2365
2365
{
@@ -2656,7 +2656,7 @@ private string ReCreateParts(UriComponents parts, ushort nonCanonical, UriFormat
2656
2656
case UriFormat . UriEscaped :
2657
2657
if ( NotAny ( Flags . UserEscaped ) )
2658
2658
{
2659
- UriHelper . EscapeString ( slice , ref dest , checkExistingEscaped : true , '?' , '#' ) ;
2659
+ UriHelper . EscapeString ( slice , ref dest , checkExistingEscaped : true , UriHelper . UnreservedReservedExceptQuestionMarkHash ) ;
2660
2660
}
2661
2661
else
2662
2662
{
@@ -2802,7 +2802,7 @@ private string ReCreateParts(UriComponents parts, ushort nonCanonical, UriFormat
2802
2802
{
2803
2803
UriHelper . EscapeString (
2804
2804
str . AsSpan ( offset , _info . Offset . Fragment - offset ) ,
2805
- ref dest , checkExistingEscaped : true , '#' ) ;
2805
+ ref dest , checkExistingEscaped : true , UriHelper . UnreservedReservedExceptHash ) ;
2806
2806
2807
2807
goto AfterQuery ;
2808
2808
}
@@ -2841,7 +2841,7 @@ private string ReCreateParts(UriComponents parts, ushort nonCanonical, UriFormat
2841
2841
{
2842
2842
UriHelper . EscapeString (
2843
2843
str . AsSpan ( offset , _info . Offset . End - offset ) ,
2844
- ref dest , checkExistingEscaped : true ) ;
2844
+ ref dest , checkExistingEscaped : true , UriHelper . UnreservedReserved ) ;
2845
2845
2846
2846
goto AfterFragment ;
2847
2847
}
@@ -4452,7 +4452,7 @@ private unsafe void GetCanonicalPath(ref ValueStringBuilder dest, UriFormat form
4452
4452
4453
4453
UriHelper . EscapeString (
4454
4454
str . Slice ( _info . Offset . Path , _info . Offset . Query - _info . Offset . Path ) ,
4455
- ref dest , checkExistingEscaped : ! IsImplicitFile , ' ? ' , '#' ) ;
4455
+ ref dest , checkExistingEscaped : ! IsImplicitFile , UriHelper . UnreservedReservedExceptQuestionMarkHash ) ;
4456
4456
}
4457
4457
else
4458
4458
{
@@ -4472,7 +4472,7 @@ private unsafe void GetCanonicalPath(ref ValueStringBuilder dest, UriFormat form
4472
4472
// CS8350 & CS8352: We can't pass `copy` and `dest` as arguments together as that could leak the scope of the above stackalloc
4473
4473
// As a workaround, re-create the Span in a way that avoids analysis
4474
4474
ReadOnlySpan < char > copySpan = MemoryMarshal . CreateReadOnlySpan ( ref copy . GetPinnableReference ( ) , copy . Length ) ;
4475
- UriHelper . EscapeString ( copySpan , ref dest , checkExistingEscaped : true, ' \\ ' ) ;
4475
+ UriHelper . EscapeString ( copySpan , ref dest , checkExistingEscaped : true, UriHelper . UnreservedReserved ) ;
4476
4476
start = dest . Length ;
4477
4477
4478
4478
copy . Dispose ( ) ;
@@ -4534,7 +4534,7 @@ private unsafe void GetCanonicalPath(ref ValueStringBuilder dest, UriFormat form
4534
4534
// CS8350 & CS8352: We can't pass `copy` and `dest` as arguments together as that could leak the scope of the above stackalloc
4535
4535
// As a workaround, re-create the Span in a way that avoids analysis
4536
4536
ReadOnlySpan < char > copySpan = MemoryMarshal. CreateReadOnlySpan( ref copy . GetPinnableReference ( ) , copy . Length ) ;
4537
- UriHelper . EscapeString ( copySpan , ref dest , checkExistingEscaped : ! IsImplicitFile , ' ? ' , '#' ) ;
4537
+ UriHelper . EscapeString ( copySpan , ref dest , checkExistingEscaped : ! IsImplicitFile , UriHelper . UnreservedReservedExceptQuestionMarkHash ) ;
4538
4538
start = dest . Length ;
4539
4539
4540
4540
copy. Dispose ( ) ;
@@ -5149,7 +5149,7 @@ protected virtual string Unescape(string path)
5149
5149
[ Obsolete ( "Uri.EscapeString has been deprecated. Use GetComponents() or Uri.EscapeDataString to escape a Uri component or a string." ) ]
5150
5150
protected static string EscapeString( string ? str ) =>
5151
5151
str is null ? string . Empty :
5152
- UriHelper . EscapeString ( str , checkExistingEscaped : true, UriHelper . UnreservedReservedTable , ' ? ' , '#' ) ;
5152
+ UriHelper . EscapeString ( str , checkExistingEscaped : true, UriHelper . UnreservedReservedExceptQuestionMarkHash ) ;
5153
5153
5154
5154
//
5155
5155
// CheckSecurity
0 commit comments