From ddb70b3a36807920956dcc63f8f0f5cff6505b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Gro=C3=9Fmann?= Date: Sun, 22 Mar 2026 22:15:52 +0100 Subject: [PATCH] fix: use IBM-1047 etoa for UFS files and SSI in httpfile.c UFS files are stored in IBM-1047 EBCDIC but http_send_file() and ssi_buffer() used the server-default etoa (CP037), producing wrong ASCII for [ ] ^ { } ~ \ | in static HTML/JS/CSS served from UFS. Use xlate_1047->etoa explicitly for UFS file data in http_send_file() and unconditionally in ssi_buffer() (SSI is UFS-only). Fixes #38 --- src/httpfile.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/httpfile.c b/src/httpfile.c index 019a218..d656825 100644 --- a/src/httpfile.c +++ b/src/httpfile.c @@ -64,10 +64,15 @@ http_send_file(HTTPC *httpc, int binary) if (len>0) { /* we read some data */ if (!binary) { - /* convert to ASCII */ - /* wtodumpf(&httpc->buf[httpc->len], len, "%s before", __func__); */ - http_etoa(&httpc->buf[httpc->len], len); - /* wtodumpf(&httpc->buf[httpc->len], len, "%s after", __func__); */ + /* convert EBCDIC to ASCII */ + if (httpc->ufp) { + /* UFS files are stored in IBM-1047 */ + http_xlate(&httpc->buf[httpc->len], len, + httpx->xlate_1047->etoa); + } else { + /* MVS datasets use server-default codepage */ + http_etoa(&httpc->buf[httpc->len], len); + } } httpc->len += len; } @@ -672,7 +677,9 @@ ssi_buffer(HTTPC *httpc, const char *buf, int len) avail = CBUFSIZE - httpc->len; if (len < avail) { memcpy(&httpc->buf[httpc->len], buf, len); - http_etoa(&httpc->buf[httpc->len], len); + /* SSI files are served from UFS (IBM-1047) */ + http_xlate(&httpc->buf[httpc->len], len, + httpx->xlate_1047->etoa); httpc->len += len; } }