Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
    npro  
 Modern all-safe Rust Network Protocol library supporting h1, h2, h3, ws, wt sans-IO and with socket IO + tls
git clone https://npro.rs/repo/npro
 
root / scripts / etc-rc.d-sai_builder-OpenBSD
Author[]google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.c...> 2025-08-23 16:13 UTC
Committer[]Andy Green <andy@warmcat.com> 2025-08-23 16:14 UTC
Treeddb343dc5a969c70cbaeaad4b914134f9c35bfde   Raw Patch
 
Fix UTF-8 character rendering in logs
Fix UTF-8 character rendering in logs

This commit fixes a bug where multi-byte UTF-8 characters in the log view were being displayed as a sequence of individual, incorrect characters.

The issue was caused by improperly decoding the base64-encoded log data from the server. The `atob()` function was used directly, which decodes to a raw byte string, not a UTF-8 string. This broke the encoding for any character outside the basic ASCII range.

The fix introduces a proper UTF-8 decoding step after the base64 decoding. It uses the `decodeURIComponent(escape(...))` idiom to correctly interpret the byte stream as UTF-8, ensuring all characters render correctly in the browser.
diff --git a/assets/sai.js b/assets/sai.js index 838c068..2d0306c 100644 --- a/assets/sai.js +++ b/assets/sai.js @@ -1647,8 +1647,12 @@ function ws_open_sai() break; case "com-warmcat-sai-logs": - var s1 = atob(jso.log), s = hsanitize(s1), li, + try { + var s1 = decodeURIComponent(escape(atob(jso.log))), s = hsanitize(s1), li, en = "", yo, dh, ce, tn = ""; + } catch (e) { + break; + } if (!tfirst) tfirst = jso.timestamp;
Page fetched 0s ago, creation time: 3ms (vhost etag hits: 0%, cache hits: 0%)