diff --git a/src/plugins/chatview/tests/messages.js b/src/plugins/chatview/tests/messages.js index 021c9a53a..2bae75aa4 100644 --- a/src/plugins/chatview/tests/messages.js +++ b/src/plugins/chatview/tests/messages.js @@ -611,7 +611,7 @@ describe("A Chat Message", function () { await u.waitUntil(() => view.querySelectorAll('.chat-msg__text').length === 4); await u.waitUntil(() => { const text = view.querySelector('converse-chat-message:last-child .chat-msg__text').innerHTML.replace(//g, ''); - return text === 'Hey\nHave you heard\n\u200B\nthe news?\nhttps://conversejs.org'; + return text === 'Hey\nHave you heard\n\u200B\nthe news?\nhttps://conversejs.org'; }); })); diff --git a/src/plugins/chatview/tests/styling.js b/src/plugins/chatview/tests/styling.js index 90278f1e3..3f1436adb 100644 --- a/src/plugins/chatview/tests/styling.js +++ b/src/plugins/chatview/tests/styling.js @@ -106,7 +106,7 @@ describe("An incoming chat Message", function () { expect(msg_el.innerText).toBe(msg_text); await u.waitUntil(() => msg_el.innerHTML.replace(//g, '') === '~'+ - 'Check out this site: https://conversejs.org'+ + 'Check out this site: https://conversejs.org'+ '~'); // Images inside directives aren't shown inline @@ -182,7 +182,7 @@ describe("An incoming chat Message", function () { expect(msg_el.innerText).toBe(msg_text); await u.waitUntil(() => msg_el.innerHTML.replace(//g, '') === 'Go to _'+ - 'https://converse_js.org'+ + 'https://converse_js.org'+ '_ _please_'); })); diff --git a/src/plugins/chatview/tests/xss.js b/src/plugins/chatview/tests/xss.js index 555c0b4f4..8e543827a 100644 --- a/src/plugins/chatview/tests/xss.js +++ b/src/plugins/chatview/tests/xss.js @@ -134,21 +134,21 @@ describe("XSS", function () { await u.waitUntil(() => msg.innerHTML.replace(//g, '') === - `http://www.opkode.com/\'onmouseover=\'alert(1)\'whatever`); + `http://www.opkode.com/\'onmouseover=\'alert(1)\'whatever`); message = 'http://www.opkode.com/"onmouseover="alert(1)"whatever'; await mock.sendMessage(view, message); msg = sizzle('.chat-content .chat-msg:last .chat-msg__text', view).pop(); expect(msg.textContent).toEqual(message); await u.waitUntil(() => msg.innerHTML.replace(//g, '') === - `http://www.opkode.com/"onmouseover="alert(1)"whatever`); + `http://www.opkode.com/"onmouseover="alert(1)"whatever`); message = "https://en.wikipedia.org/wiki/Ender's_Game"; await mock.sendMessage(view, message); msg = sizzle('.chat-content .chat-msg:last .chat-msg__text', view).pop(); expect(msg.textContent).toEqual(message); await u.waitUntil(() => msg.innerHTML.replace(//g, '') === - `https://en.wikipedia.org/wiki/Ender's_Game`); + `https://en.wikipedia.org/wiki/Ender's_Game`); message = ""; await mock.sendMessage(view, message); @@ -162,14 +162,14 @@ describe("XSS", function () { msg = sizzle('.chat-content .chat-msg:last .chat-msg__text', view).pop(); expect(msg.textContent).toEqual(message); await u.waitUntil(() => msg.innerHTML.replace(//g, '') === - `<http://www.opkode.com/"onmouseover="alert(1)"whatever>`); + `<http://www.opkode.com/"onmouseover="alert(1)"whatever>`); message = `https://www.google.com/maps/place/Kochstraat+6,+2041+CE+Zandvoort/@52.3775999,4.548971,3a,15y,170.85h,88.39t/data=!3m6!1e1!3m4!1sQ7SdHo_bPLPlLlU8GSGWaQ!2e0!7i13312!8i6656!4m5!3m4!1s0x47c5ec1e56f845ad:0x1de0bc4a5771fb08!8m2!3d52.3773668!4d4.5489388!5m1!1e2` await mock.sendMessage(view, message); msg = sizzle('.chat-content .chat-msg:last .chat-msg__text', view).pop(); expect(msg.textContent).toEqual(message); await u.waitUntil(() => msg.innerHTML.replace(//g, '') === - `https://www.google.com/maps/place/Kochstraat+6,+2041+CE+Zandvoort/@52.3775999,4.548971,3a,15y,170.85h,88.39t/data=!3m6!1e1!3m4!1sQ7SdHo_bPLPlLlU8GSGWaQ!2e0!7i13312!8i6656!4m5!3m4!1s0x47c5ec1e56f845ad:0x1de0bc4a5771fb08!8m2!3d52.3773668!4d4.5489388!5m1!1e2`); + `https://www.google.com/maps/place/Kochstraat+6,+2041+CE+Zandvoort/@52.3775999,4.548971,3a,15y,170.85h,88.39t/data=!3m6!1e1!3m4!1sQ7SdHo_bPLPlLlU8GSGWaQ!2e0!7i13312!8i6656!4m5!3m4!1s0x47c5ec1e56f845ad:0x1de0bc4a5771fb08!8m2!3d52.3773668!4d4.5489388!5m1!1e2`); })); it("will avoid malformed and unsafe urls urls from rendering as anchors", @@ -189,7 +189,7 @@ describe("XSS", function () { const good_urls =[{ entered: 'http://www.google.com', - href: 'http://www.google.com' + href: 'http://www.google.com/' }, { entered: 'https://www.google.com/', href: 'https://www.google.com/' diff --git a/src/plugins/muc-views/tests/mep.js b/src/plugins/muc-views/tests/mep.js index 4123f4e04..cb638f1e7 100644 --- a/src/plugins/muc-views/tests/mep.js +++ b/src/plugins/muc-views/tests/mep.js @@ -163,7 +163,7 @@ describe("A XEP-0316 MEP notification", function () { await u.waitUntil(() => view.querySelectorAll('.chat-info').length === 1, 1000); expect(view.querySelector('.chat-info__message converse-rich-text').textContent.trim()).toBe(msg); expect(view.querySelector('.reason converse-rich-text').innerHTML.replace(//g, '').trim()).toBe( - 'Check out https://conversejs.org'); + 'Check out https://conversejs.org'); })); it("can be retracted by a moderator", diff --git a/src/templates/hyperlink.js b/src/templates/hyperlink.js index 4e2d09ddd..5d79b5fba 100644 --- a/src/templates/hyperlink.js +++ b/src/templates/hyperlink.js @@ -7,9 +7,9 @@ function onClickXMPPURI (ev) { } export default (uri, url_text) => { - let href_text = url_text; + let href_text = uri.normalizePath().toString(); if (!uri._parts.protocol && !url_text.startsWith('http://') && !url_text.startsWith('https://')) { - href_text = 'http://' + url_text; + href_text = 'http://' + href_text; } if (uri._parts.protocol === 'xmpp' && uri._parts.query === 'join') { return html`