Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
OpportunityLiu committed Apr 28, 2019
1 parent f3b24bc commit 1163976
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions EhTagClient/MarkdigExt/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static string NormalizeUri(string url)
for (var i = 0; i < uri.Length; i++)
{
var ch = uri[i];
if (char.IsWhiteSpace(ch) || "()".IndexOf(ch) >= 0)
if ("()".IndexOf(ch) >= 0 || char.IsWhiteSpace(ch) || char.IsControl(ch))
{
var b = (Span<byte>)stackalloc byte[12];
var l = encodeChar(uri.Slice(i, 1), b);
Expand All @@ -32,7 +32,10 @@ public static string NormalizeUri(string url)
else if (ch == '%' && i + 2 < uri.Length && isHexChar(uri[i + 1]) && isHexChar(uri[i + 2]))
{
var bc = byte.Parse(uri.Slice(i + 1, 2), System.Globalization.NumberStyles.HexNumber);
if ("\\\"!*'();:@&=+$,/?#[]".IndexOf((char)bc) >= 0 || char.IsWhiteSpace((char)bc))
if (bc < 128 &&
("\\\"!*'();:@&=+$,/?#[]".IndexOf((char)bc) >= 0
|| char.IsControl((char)bc)
|| char.IsWhiteSpace((char)bc)))
{
var b = (Span<byte>)stackalloc byte[4 * 3];
var l = enc.GetBytes(uri.Slice(i, 3), b);
Expand Down

0 comments on commit 1163976

Please sign in to comment.