From 294176c728a6ed6f4eb77053342ebf33ad6ce699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 9 Jun 2026 16:17:11 +0200 Subject: [PATCH] HTML encode target URL --- .../WebAssemblyNetDebugProxyAppBuilderExtensions.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mono/wasm/host/DevServer/WebAssemblyNetDebugProxyAppBuilderExtensions.cs b/src/mono/wasm/host/DevServer/WebAssemblyNetDebugProxyAppBuilderExtensions.cs index c15f8948b2e353..a1430cfa054fae 100644 --- a/src/mono/wasm/host/DevServer/WebAssemblyNetDebugProxyAppBuilderExtensions.cs +++ b/src/mono/wasm/host/DevServer/WebAssemblyNetDebugProxyAppBuilderExtensions.cs @@ -333,6 +333,9 @@ public async Task Display(HttpContext context) var debuggerTabsListUrl = $"{_browserHost}/json"; IEnumerable availableTabs; + var targetApplicationUrlEncoded = WebUtility.HtmlEncode(targetApplicationUrl.ToString()); + var debuggerTabsListUrlEncoded = WebUtility.HtmlEncode(debuggerTabsListUrl); + try { availableTabs = await GetOpenedBrowserTabs(); @@ -342,17 +345,17 @@ public async Task Display(HttpContext context) await context.Response.WriteAsync($@"

Unable to find debuggable browser tab

- Could not get a list of browser tabs from {debuggerTabsListUrl}. + Could not get a list of browser tabs from {debuggerTabsListUrlEncoded}. Ensure your browser is running with debugging enabled.

Resolution

If you are using Google Chrome or Chromium for your development, follow these instructions:

- {GetLaunchChromeInstructions(targetApplicationUrl.ToString())} + {GetLaunchChromeInstructions(targetApplicationUrlEncoded)}

If you are using Microsoft Edge (80+) for your development, follow these instructions:

- {GetLaunchEdgeInstructions(targetApplicationUrl.ToString())} + {GetLaunchEdgeInstructions(targetApplicationUrlEncoded)}

This should launch a new browser window with debugging enabled..

Underlying exception:

@@ -378,8 +381,8 @@ Ensure your browser is running with debugging enabled. var suffix = string.IsNullOrEmpty(targetApplicationUrl) ? string.Empty - : $" matching the URL {WebUtility.HtmlEncode(targetApplicationUrl)}"; - await context.Response.WriteAsync($"

The list of targets returned by {WebUtility.HtmlEncode(debuggerTabsListUrl)} contains no entries{suffix}.

"); + : $" matching the URL {targetApplicationUrlEncoded}"; + await context.Response.WriteAsync($"

The list of targets returned by {debuggerTabsListUrlEncoded} contains no entries{suffix}.

"); await context.Response.WriteAsync("

Make sure your browser is displaying the target application.

"); } else