Unfurls: Remove URL check
Url parameters mean that we don't get a match even when the URLs actually match. Could potentially use URI.js but gets cumbersome and since we restrict to metadata coming from the MUC service (which we trust) I think it's OK to remove it.
This commit is contained in:
parent
68ca5dd279
commit
64fd0ebcf6
17
package-lock.json
generated
17
package-lock.json
generated
@ -2757,7 +2757,8 @@
|
||||
"dependencies": {
|
||||
"filesize": {
|
||||
"version": "6.1.0",
|
||||
"resolved": false
|
||||
"resolved": "https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz",
|
||||
"integrity": "sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg=="
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "8.1.0",
|
||||
@ -2813,20 +2814,22 @@
|
||||
},
|
||||
"localforage": {
|
||||
"version": "1.7.3",
|
||||
"resolved": false,
|
||||
"resolved": "https://registry.npmjs.org/localforage/-/localforage-1.7.3.tgz",
|
||||
"integrity": "sha512-1TulyYfc4udS7ECSBT2vwJksWbkwwTX8BzeUIiq8Y07Riy7bDAAnxDaPU/tWyOVmQAcWJIEIFP9lPfBGqVoPgQ==",
|
||||
"requires": {
|
||||
"lie": "3.1.1"
|
||||
}
|
||||
},
|
||||
"pluggable.js": {
|
||||
"version": "2.0.1",
|
||||
"resolved": false,
|
||||
"resolved": "https://registry.npmjs.org/pluggable.js/-/pluggable.js-2.0.1.tgz",
|
||||
"integrity": "sha512-SBt6v6Tbp20Jf8hU0cpcc/+HBHGMY8/Q+yA6Ih0tBQE8tfdZ6U4PRG0iNvUUjLx/hVyOP53n0UfGBymlfaaXCg==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.11"
|
||||
}
|
||||
},
|
||||
"skeletor.js": {
|
||||
"version": "0.0.1",
|
||||
"version": "github:skeletorjs/skeletor#bf6d9c86f9fcf224fa9d9af5a25380b77aa4b561",
|
||||
"from": "github:skeletorjs/skeletor#bf6d9c86f9fcf224fa9d9af5a25380b77aa4b561",
|
||||
"requires": {
|
||||
"lodash": "^4.17.14"
|
||||
@ -2834,7 +2837,11 @@
|
||||
},
|
||||
"strophe.js": {
|
||||
"version": "github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f",
|
||||
"from": "strophe.js@github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f"
|
||||
"from": "strophe.js@github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f",
|
||||
"requires": {
|
||||
"abab": "^2.0.3",
|
||||
"xmldom": "^0.1.27"
|
||||
}
|
||||
},
|
||||
"twemoji": {
|
||||
"version": "12.1.5",
|
||||
|
@ -12,7 +12,18 @@
|
||||
|
||||
.card--unfurl {
|
||||
margin: 1em 0;
|
||||
max-width: 18rem;
|
||||
@include media-breakpoint-down(sm) {
|
||||
max-width: 95%;
|
||||
}
|
||||
@include media-breakpoint-up(md) {
|
||||
max-width: 75%;
|
||||
}
|
||||
@include media-breakpoint-up(lg) {
|
||||
max-width: 66%;
|
||||
}
|
||||
@include media-breakpoint-up(xl) {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.show-msg-author-modal {
|
||||
|
@ -102,44 +102,6 @@ describe("A Groupchat Message", function () {
|
||||
done();
|
||||
}));
|
||||
|
||||
it("will not render an unfurl based on a URL not in the original message", mock.initConverse(['chatBoxesFetched'], {}, async function (done, _converse) {
|
||||
const nick = 'romeo';
|
||||
const muc_jid = 'lounge@montague.lit';
|
||||
await mock.openAndEnterChatRoom(_converse, muc_jid, nick);
|
||||
const view = _converse.api.chatviews.get(muc_jid);
|
||||
|
||||
const message_stanza = u.toStanza(`
|
||||
<message xmlns="jabber:client" type="groupchat" from="${muc_jid}/arzu" xml:lang="en" to="${_converse.jid}" id="eda6c790-b4f3-4c07-b5e2-13fff99e6c04">
|
||||
<body>https://www.youtube.com/watch?v=dQw4w9WgXcQ</body>
|
||||
<active xmlns="http://jabber.org/protocol/chatstates"/>
|
||||
<origin-id xmlns="urn:xmpp:sid:0" id="eda6c790-b4f3-4c07-b5e2-13fff99e6c04"/>
|
||||
<stanza-id xmlns="urn:xmpp:sid:0" by="${muc_jid}" id="8f7613cc-27d4-40ca-9488-da25c4baf92a"/>
|
||||
<markable xmlns="urn:xmpp:chat-markers:0"/>
|
||||
</message>`);
|
||||
_converse.connection._dataRecv(mock.createRequest(message_stanza));
|
||||
const el = await u.waitUntil(() => view.querySelector('.chat-msg__text'));
|
||||
expect(el.textContent).toBe('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
|
||||
|
||||
spyOn(view.model, 'handleMetadataFastening').and.callThrough();
|
||||
|
||||
const metadata_stanza = u.toStanza(`
|
||||
<message xmlns="jabber:client" from="${muc_jid}" to="${_converse.jid}" type="groupchat">
|
||||
<apply-to xmlns="urn:xmpp:fasten:0" id="eda6c790-b4f3-4c07-b5e2-13fff99e6c04">
|
||||
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:site_name" content="YouTube" />
|
||||
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:url" content="https://www.youtube.com/watch?v=tmY-G6sngk8" />
|
||||
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:title" content="Rick Astley - Never Gonna Give You Up (Video)" />
|
||||
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:image" content="https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg" />
|
||||
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:description" content="Rick Astley&#39;s official music video for "Never Gonna Give You Up" Listen to Rick Astley: https://RickAstley.lnk.to/_listenYD Subscribe to the official Rick Ast..." />
|
||||
</apply-to>
|
||||
</message>`);
|
||||
_converse.connection._dataRecv(mock.createRequest(metadata_stanza));
|
||||
|
||||
await u.waitUntil(() => view.model.handleMetadataFastening.calls.count());
|
||||
expect(view.model.handleMetadataFastening.calls.first().returnValue).toBe(false);
|
||||
expect(view.querySelector('converse-message-unfurl')).toBe(null);
|
||||
done();
|
||||
}));
|
||||
|
||||
it("will not render an unfurl received from a MUC participant", mock.initConverse(['chatBoxesFetched'], {}, async function (done, _converse) {
|
||||
const nick = 'romeo';
|
||||
const muc_jid = 'lounge@montague.lit';
|
||||
|
@ -2133,12 +2133,6 @@ const ChatRoomMixin = {
|
||||
}
|
||||
const message = this.messages.findWhere({'origin_id': attrs.ogp_for_id});
|
||||
if (message) {
|
||||
if (!attrs['og:url'] || !message.get('body').includes(attrs['og:url'])) {
|
||||
// For security purposes, we don't show metadata for a URL not actually
|
||||
// included in the original message
|
||||
log.warn("Not showing OGP data because we can't find the relevant URL in the original message");
|
||||
return false;
|
||||
}
|
||||
const old_list = (message.get('ogp_metadata') || []);
|
||||
if (old_list.filter(m => m['og:url'] === attrs['og:url']).length) {
|
||||
// Don't add metadata for the same URL again
|
||||
|
Loading…
Reference in New Issue
Block a user