URL: <https://savannah.gnu.org/bugs/?68429>
Summary: UTF-8 double-encoding in AddStr/AddStrn
Group: GNU Screen
Submitter: tobwen
Submitted: Sun 07 Jun 2026 03:22:40 PM UTC
Category: encoding
Severity: 3 - Normal
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Unlocked
Release: Cur Dev Sources
Fixed Release: None
Planned Release: 5.0.2
Work Required: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Sun 07 Jun 2026 03:22:40 PM UTC By: Tobias Wendorff <tobwen>
== Finding ==
session name `öpnv` (UTF-8 0xC3 0xB6) produces `öpnv` (0xC3 0x83 0xC2
0xB6) in the detach message.
== Analysis ==
When D_encoding == UTF8, AddStr() and AddStrn() passed each byte through
AddUtf8(), which interprets its argument as a Unicode code point and
re-encodes it as UTF-8. Since input strings are already system-encoded (UTF-8
from filesystem, escape sequences, user text), multi-byte sequences get
double-encoded.
== Fix ==
Output raw bytes via AddChar() instead of per-byte AddUtf8().
ASCII callers are unaffected (identical in Latin-1 and UTF-8). The correct
code-point-to-UTF-8 path via AddUtf8(c) remains at the RAW_PUTCHAR
character-output path.
== Tests ==
Added regression test tests/test-addstr.c.
== Patch ==
Patchfile is attached.
_______________________________________________________
File Attachments:
Name: bugfix-addstr-utf8.patch Size: 7.5KiB
<https://file.savannah.gnu.org/file/bugfix-addstr-utf8.patch?file_id=58690>
AGPL NOTICE
These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://git.savannah.nongnu.org/cgit/administration/savane.git/snapshot/savane-c36938be85ff6c1b727bc7dd7fd30e48f9142870.tar.gz
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68429>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
