Skip to content

Commit

Permalink
Remove two always false properties in UriSyntax (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar authored and MihaZupan committed Jan 15, 2020
1 parent 6d89321 commit b8f8815
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 100 deletions.
44 changes: 4 additions & 40 deletions src/libraries/System.Private.Uri/src/System/IriHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,41 +95,8 @@ internal static bool CheckIsReserved(char ch, UriComponents component)
{
return (component == (UriComponents)0) ? UriHelper.IsGenDelim(ch) : false;
}
else if (UriParser.DontEnableStrictRFC3986ReservedCharacterSets)
{
// Since we aren't enabling strict RFC 3986 reserved sets, we stick with the old behavior
// (for app-compat) which was a broken mix of RFCs 2396 and 3986.
switch (component)
{
case UriComponents.UserInfo:
if (ch == '/' || ch == '?' || ch == '#' || ch == '[' || ch == ']' || ch == '@')
return true;
break;
case UriComponents.Host:
if (ch == ':' || ch == '/' || ch == '?' || ch == '#' || ch == '[' || ch == ']' || ch == '@')
return true;
break;
case UriComponents.Path:
if (ch == '/' || ch == '?' || ch == '#' || ch == '[' || ch == ']')
return true;
break;
case UriComponents.Query:
if (ch == '#' || ch == '[' || ch == ']')
return true;
break;
case UriComponents.Fragment:
if (ch == '#' || ch == '[' || ch == ']')
return true;
break;
default:
break;
}
return false;
}
else
{
return (UriHelper.RFC3986ReservedMarks.IndexOf(ch) >= 0);
}

return UriHelper.RFC3986ReservedMarks.IndexOf(ch) >= 0;
}

//
Expand Down Expand Up @@ -276,11 +243,8 @@ internal static unsafe string EscapeUnescapeIri(char* pInput, int start, int end
{
if (CheckIriUnicodeRange(ch, component == UriComponents.Query))
{
if (!UriHelper.IsBidiControlCharacter(ch) || !UriParser.DontKeepUnicodeBidiFormattingCharacters)
{
// copy it
dest.Append(pInput[next]);
}
// copy it
dest.Append(pInput[next]);
}
else
{
Expand Down
17 changes: 3 additions & 14 deletions src/libraries/System.Private.Uri/src/System/UriHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ static void EnsureCapacity(char[]? dest, int destSize, int requiredSize)
EscapeAsciiChar((char)encodedBytes[l], ref dest);
}
}
else if (!UriHelper.IsBidiControlCharacter(unescapedCharsPtr[j]) || !UriParser.DontKeepUnicodeBidiFormattingCharacters)
else
{
//copy chars
dest.Append(unescapedCharsPtr[j]);
Expand Down Expand Up @@ -708,7 +708,6 @@ internal static char EscapedAscii(char digit, char next)
}

internal const string RFC3986ReservedMarks = @";/?:@&=+$,#[]!'()*";
private const string RFC2396ReservedMarks = @";/?:@&=+$,";
private const string AdditionalUnsafeToUnescape = @"%\#"; // While not specified as reserved, these are still unsafe to unescape.

// When unescaping in safe mode, do not unescape the RFC 3986 reserved set:
Expand All @@ -729,18 +728,8 @@ internal static bool IsNotSafeForUnescape(char ch)
{
return true;
}
else if (UriParser.DontEnableStrictRFC3986ReservedCharacterSets)
{
if ((ch != ':' && (RFC2396ReservedMarks.IndexOf(ch) >= 0) || (AdditionalUnsafeToUnescape.IndexOf(ch) >= 0)))
{
return true;
}
}
else if ((RFC3986ReservedMarks.IndexOf(ch) >= 0) || (AdditionalUnsafeToUnescape.IndexOf(ch) >= 0))
{
return true;
}
return false;

return RFC3986ReservedMarks.IndexOf(ch) >= 0 || AdditionalUnsafeToUnescape.IndexOf(ch) >= 0;
}

// "Reserved" and "Unreserved" characters are based on RFC 3986.
Expand Down
20 changes: 0 additions & 20 deletions src/libraries/System.Private.Uri/src/System/UriSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,6 @@ public abstract partial class UriParser
internal const int NoDefaultPort = -1;
private const int c_InitialTableSize = 25;

internal static bool DontEnableStrictRFC3986ReservedCharacterSets
{
// In .NET Framework this would test against an AppContextSwitch. Since this is a potentially
// breaking change, we'll leave in the system used to disable it.
get
{
return false;
}
}

internal static bool DontKeepUnicodeBidiFormattingCharacters
{
// In .NET Framework this would test against an AppContextSwitch. Since this is a potentially
// breaking change, we'll leave in the system used to disable it.
get
{
return false;
}
}

private class BuiltInUriParser : UriParser
{
//
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="Fakes\FakeUri.cs" />
<Compile Include="Fakes\FakeUriParser.cs" />
<Compile Include="IriEscapeUnescapeTest.cs" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit b8f8815

Please sign in to comment.