Server text that one of the library's own messages quotes — a station's shortname,
water, number or uuid in the ambiguous-station message — made safe and short: white
space (line breaks, tabs, U+2028/U+2029 included) folded to one space, so it stays on
one line and cannot forge a log record; the other control characters (C0, DEL, C1: ESC
and the 8-bit CSI would steer a terminal) and the bidi controls dropped; trimmed and cut
at max characters (MAX_QUOTED_LENGTH, 200). Only the first MAX_SERVER_TEXT (16 384)
units are read, and every step is a linear regex replace, so a hostile station field costs
neither seconds nor the heap. The data the text came from is kept as the server sent it.
Server text that one of the library's own messages quotes — a station's shortname, water, number or uuid in the ambiguous-station message — made safe and short: white space (line breaks, tabs, U+2028/U+2029 included) folded to one space, so it stays on one line and cannot forge a log record; the other control characters (C0, DEL, C1: ESC and the 8-bit CSI would steer a terminal) and the bidi controls dropped; trimmed and cut at
maxcharacters (MAX_QUOTED_LENGTH, 200). Only the firstMAX_SERVER_TEXT(16 384) units are read, and every step is a linear regex replace, so a hostile station field costs neither seconds nor the heap. The data the text came from is kept as the server sent it.