Commit 4018dd95 authored by JC Brand's avatar JC Brand

Fixes #1764: Incorrect URI encoding in references

parent 2dae07fa
......@@ -29,6 +29,7 @@
- #1666: Allow scrolling of the OMEMO fingerprints list
- #1691: Fix `collection.chatbox is undefined` errors
- #1767: `credentials_url` is not called when logging out and then in again
- #1764: Incorrect URI encoding in "mention" references
- #1772: `_converse.api.contact.add(jid, nick)` fails, says not a function
- #1791: `auto_focus` set to `false` is ignored when switching back to a MUC
- #1792: Fix: modals don't have scrollbars
......
......@@ -915,7 +915,50 @@
[text, references] = view.model.parseTextForReferences('nice website https://darnuria.eu/@darnuria');
expect(references.length).toBe(0);
expect(text).toBe('nice website https://darnuria.eu/@darnuria');
done();
}));
it("properly encodes the URIs in sent out references",
mock.initConverse(
['rosterGroupsFetched'], {},
async function (done, _converse) {
const muc_jid = 'lounge@montague.lit';
await test_utils.openAndEnterChatRoom(_converse, muc_jid, 'tom');
const view = _converse.api.roomviews.get(muc_jid);
_converse.connection._dataRecv(test_utils.createRequest(
$pres({
'to': 'tom@montague.lit/resource',
'from': `lounge@montague.lit/Link Mauve`
})
.c('x', {xmlns: Strophe.NS.MUC_USER})
.c('item', {
'affiliation': 'none',
'role': 'participant'
})));
const textarea = view.el.querySelector('textarea.chat-textarea');
textarea.value = 'hello @Link Mauve'
const enter_event = {
'target': textarea,
'preventDefault': function preventDefault () {},
'stopPropagation': function stopPropagation () {},
'keyCode': 13 // Enter
}
spyOn(_converse.connection, 'send');
view.onKeyDown(enter_event);
await new Promise(resolve => view.once('messageInserted', resolve));
const msg = _converse.connection.send.calls.all()[0].args[0];
expect(msg.toLocaleString())
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.nodeTree.getAttribute("id")}" `+
`to="lounge@montague.lit" type="groupchat" `+
`xmlns="jabber:client">`+
`<body>hello Link Mauve</body>`+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<reference begin="6" end="16" type="mention" uri="xmpp:lounge@montague.lit/Link%20Mauve" xmlns="urn:xmpp:reference:0"/>`+
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`);
done();
}));
......
......@@ -786,9 +786,9 @@ converse.plugins.add('converse-muc', {
'type': 'mention'
};
if (occupant.get('jid')) {
obj.uri = `xmpp:${occupant.get('jid')}`;
obj.uri = encodeURI(`xmpp:${occupant.get('jid')}`);
} else {
obj.uri = `xmpp:${this.get('jid')}/${occupant.get('nick')}`;
obj.uri = encodeURI(`xmpp:${this.get('jid')}/${occupant.get('nick')}`);
}
return obj;
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment