message, caption: mention offsets point past characters XML cannot carry #24
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
message senddrops the characters XML 1.0 forbids from the body (XmlText)and then checks the caller's
-mentionsagainst the cleaned body withoutmoving them. When something is stripped before a mention, its
<reference/>/<mention/>(and the stored row) point at the wrong text.Captions (
send_file,send_album,set_caption) have the same problem.Spec
XEP-0426 0.3.0 §2: offsets index the body as sent, counted in code points.
Steps to reproduce
30..34is@Beein the body as given.Expected
<reference begin='28' end='32'/>, which is@Beein the body sent (or the send refused).Actual
30..34now coversee e.The same happens in an OMEMO chat (reproduced by hand in anotherim-js
0.8.0-beta5 on 2026-11-08 with OMEMO on): the body sealed in the envelope is
stripped as well, and the mention keeps its old offsets. In a client this
shows as the wrong text highlighted, or no highlight at all when the shifted
end runs past the body, in the sender's own row too. A paste of
hi\x01\x02before a picked@Nickis enough.Root cause
tacky/xmpp/modules/message.tcl:5089-5091(1dae0a6c):XmlText, thenCheckMentionson the cleaned body.CaptionMentionsshifts only for thetrimmed leading space.
Affected versions
v1.2.0-rc2 and v1.2.0 (
1dae0a6c).Interop runs
Fixed upstream in v1.2.1 by
67d627cf("message: mentions move past the characters XML cannot carry, so a mention still marks the words it marked (interop C3)"). It has the same code and tests as this branch (git patch-id), so this is closed as a duplicate.Found by hand since filing, in anotherim-js
developwith libtackydevelop56d29734:message sendrefuses the whole send, and the message silently isn't sent.begin='3' end='21'(exactly@Nick).