fix(protocol): preserve nested XML forward lookup keys

This commit is contained in:
手瓜一十雪 committed 2026-10-18 18:59:22 +08:00
1 parent a69ec6fedb
commit bdf224cbc9
3 files changed
+248 -1

No files matched your search

@@ -137,9 +137,12 @@ function decodeRichMsgCard(
if (svcId === 35) {
const match = /\bm_resid="([^"]+)"/.exec(content);
// XML forwards link bundled inner messages by m_fileName, just as
// LightApp forwards use uniseq. Keep it for the outer payload lookup.
const fileName = /\bm_fileName="([^"]+)"/.exec(content)?.[1];
return {
element: match
? { type: 'forward', resId: match[1] }
? { type: 'forward', resId: match[1], forwardUuid: fileName }
: { type: 'xml', text: content, subType: svcId },
error: null,
inputBytes: data.length,
@@ -218,6 +218,34 @@ describe('decodeRichBody / forward LightApp', () => {
expect(out[0]!.type).toBe('json');
});
it.each([false, true])(
'preserves the XML forward filename for nested lookup (compressed=%s, #529)',
(compressed) => {
const xml = Buffer.from(
'<msg serviceID="35" m_resid="inner-xml-res" m_fileName="inner-xml-key" />',
);
const body: MessageBody = {
richText: {
elems: [
{
richMsg: {
serviceId: 35,
template1: Buffer.concat([
Buffer.from([compressed ? 1 : 0]),
compressed ? deflateSync(xml) : xml,
]),
},
},
],
},
};
expect(decodeRichBody(body, true)).toEqual([
{ type: 'forward', resId: 'inner-xml-res', forwardUuid: 'inner-xml-key' },
]);
},
);
it('still decodes the legacy richMsg serviceID=35 path (backward compat with mobile QQ)', () => {
// Older clients (and some bridges) still emit the m_resid XML
// shape. The decoder must keep treating it as a forward element