From 92a35606ed960c425e25be05b8741030cb893a88 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Thu, 31 Jul 2025 17:23:11 +0900 Subject: [PATCH] Improve XML escaping, WebSocket buffer, and editor style Replaced HTML encoding with SecurityElement.Escape for XML escaping in ChromiumDevTools. Made WebSocketManager's receive buffer size configurable with a default of 65536 bytes. Updated editor.html to use 'color: inherit' for banner link hover to maintain contrast. --- .../WelsonJS.Launcher/ResourceTools/ChromiumDevTools.cs | 3 ++- WelsonJS.Toolkit/WelsonJS.Launcher/WebSocketManager.cs | 4 ++-- WelsonJS.Toolkit/WelsonJS.Launcher/editor.html | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/ChromiumDevTools.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/ChromiumDevTools.cs index 733e01f..857c2ac 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/ChromiumDevTools.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/ChromiumDevTools.cs @@ -8,6 +8,7 @@ using System.IO; using System.Net; using System.Net.Http; using System.Net.WebSockets; +using System.Security; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -128,7 +129,7 @@ namespace WelsonJS.Launcher.ResourceTools private string EscapeXml(string text) { - return WebUtility.HtmlEncode(text); + return SecurityElement.Escape(text); } } } diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/WebSocketManager.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/WebSocketManager.cs index fe22675..5d35889 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/WebSocketManager.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/WebSocketManager.cs @@ -103,7 +103,7 @@ namespace WelsonJS.Launcher } } - public async Task SendAndReceiveAsync(string host, int port, string path, string message, int timeoutSeconds) + public async Task SendAndReceiveAsync(string host, int port, string path, string message, int timeoutSeconds, int bufferSize = 65536) { var buffer = Encoding.UTF8.GetBytes(message); CancellationTokenSource cts = timeoutSeconds > 0 @@ -115,7 +115,7 @@ namespace WelsonJS.Launcher ClientWebSocket ws = await GetOrCreateAsync(host, port, path); - byte[] recvBuffer = new byte[4096]; + byte[] recvBuffer = new byte[bufferSize]; WebSocketReceiveResult result = await ws.ReceiveAsync(new ArraySegment(recvBuffer), cts.Token); return Encoding.UTF8.GetString(recvBuffer, 0, result.Count); } diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/editor.html b/WelsonJS.Toolkit/WelsonJS.Launcher/editor.html index c2061c0..ec3ecdb 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/editor.html +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/editor.html @@ -47,7 +47,7 @@ .banner a:hover { text-decoration: none; font-weight: bold; - color: #000; + color: inherit; /* keeps contrast consistent */ }