Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Don't need to escape special characters anymore
  • Loading branch information
thaystg authored Nov 11, 2022
commit 19e4a3d4cb301e463be530a5b6a0f2bab40ea8f7
30 changes: 1 addition & 29 deletions src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,7 @@ internal SourceFile(AssemblyInfo assembly, int id, DocumentHandle docHandle, Uri
this.DebuggerFileName = url.Replace("\\", "/").Replace(":", "");
this.BreakableLines = new List<int>();

var urlWithSpecialCharCodedHex = EscapeAscii(url);
this.SourceUri = new Uri((Path.IsPathRooted(url) ? "file://" : "") + urlWithSpecialCharCodedHex, UriKind.RelativeOrAbsolute);
this.SourceUri = new Uri((Path.IsPathRooted(url) ? "file://" : "") + url, UriKind.RelativeOrAbsolute);
if (SourceUri.IsFile && File.Exists(SourceUri.LocalPath))
{
this.Url = this.SourceUri.ToString();
Expand All @@ -1200,33 +1199,6 @@ internal SourceFile(AssemblyInfo assembly, int id, DocumentHandle docHandle, Uri
}
}

private static string EscapeAscii(string path)
{
var builder = new StringBuilder();
foreach (char c in path)
{
switch (c)
{
case var _ when c >= 'a' && c <= 'z':
case var _ when c >= 'A' && c <= 'Z':
case var _ when char.IsDigit(c):
case var _ when c > 255:
case var _ when c == '+' || c == ':' || c == '.' || c == '-' || c == '_' || c == '~':
builder.Append(c);
break;
case var _ when c == Path.DirectorySeparatorChar:
case var _ when c == Path.AltDirectorySeparatorChar:
case var _ when c == '\\':
builder.Append(c);
break;
default:
builder.Append(string.Format($"%{((int)c):X2}"));
break;
}
}
return builder.ToString();
}

internal void AddMethod(MethodInfo mi)
{
if (!this.methods.ContainsKey(mi.Token))
Expand Down