fix(prefs): use magic sentinel to validate page_order

Previously page_order_set status was inferred from page_order[0] being
in 1..11, so a single junk byte in that range falsely triggered
custom-order mode. Add explicit page_order_set magic (0xA5) written
alongside the array; pre-magic saves are migrated once on load when
their first byte still passes the legacy range check.

Also fix(ui): keep "@[nick] " prefix out of placeholder expansion in
QuickMsgScreen reply path, so a nick containing a token like {loc}
isn't substituted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-24 19:53:05 +02:00
co-authored by Claude Sonnet 4.6
parent 10b2629b36
commit e2d59b9a3d
5 changed files with 26 additions and 7 deletions
@@ -1185,10 +1185,17 @@ public:
if (res == KeyboardWidget::CANCELLED) {
_phase = MSG_PICK;
} else if (res == KeyboardWidget::DONE) {
int min_len = _reply_mode ? (int)strlen(_reply_prefix) : 0;
if (_kb.len > min_len) {
int prefix_len = _reply_mode ? (int)strlen(_reply_prefix) : 0;
if (_kb.len > prefix_len) {
// Expand only the body — prefix "@[nick] " is preserved verbatim, so a nick
// that happens to contain a placeholder token isn't substituted.
char expanded[KB_MAX_LEN + 1];
expandMsg(_kb.buf, expanded, sizeof(expanded));
if (prefix_len > 0) {
memcpy(expanded, _kb.buf, prefix_len);
expandMsg(_kb.buf + prefix_len, expanded + prefix_len, sizeof(expanded) - prefix_len);
} else {
expandMsg(_kb.buf, expanded, sizeof(expanded));
}
bool ok = sendText(expanded);
afterSend(ok, expanded);
}