2
0
Эх сурвалжийг харах

Remove line-breaks from message image markup

We use `white-space: pre-wrap` to render the messages, so line-breaks in
the markup add unnecessary space.
JC Brand 4 жил өмнө
parent
commit
1598640c80

+ 7 - 7
src/plugins/muc-views/tests/xss.js

@@ -11,13 +11,13 @@ describe("XSS", function () {
 
             await mock.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
             /* <presence xmlns="jabber:client" to="jc@chat.example.org/converse.js-17184538"
-                *      from="oo@conference.chat.example.org/&lt;img src=&quot;x&quot; onerror=&quot;alert(123)&quot;/&gt;">
-                *   <x xmlns="http://jabber.org/protocol/muc#user">
-                *    <item jid="jc@chat.example.org/converse.js-17184538" affiliation="owner" role="moderator"/>
-                *    <status code="110"/>
-                *   </x>
-                * </presence>"
-                */
+             *      from="oo@conference.chat.example.org/&lt;img src=&quot;x&quot; onerror=&quot;alert(123)&quot;/&gt;">
+             *   <x xmlns="http://jabber.org/protocol/muc#user">
+             *    <item jid="jc@chat.example.org/converse.js-17184538" affiliation="owner" role="moderator"/>
+             *    <status code="110"/>
+             *   </x>
+             * </presence>"
+             */
             const presence = $pres({
                     to:'romeo@montague.lit/pda',
                     from:"lounge@montague.lit/&lt;img src=&quot;x&quot; onerror=&quot;alert(123)&quot;/&gt;"

+ 2 - 4
src/shared/directives/image.js

@@ -6,16 +6,14 @@ import { html } from 'lit';
 
 class ImageDirective extends AsyncDirective {
     render (src, href, onLoad, onClick) {
-        return html`
-            <a href="${href}" class="chat-image__link" target="_blank" rel="noopener"
+        return html`<a href="${href}" class="chat-image__link" target="_blank" rel="noopener"
                 ><img
                     class="chat-image img-thumbnail"
                     src="${src}"
                     @click=${onClick}
                     @error=${() => this.onError(src, href, onLoad, onClick)}
                     @load=${onLoad}
-            /></a>
-        `;
+            /></a>`;
     }
 
     onError (src, href, onLoad, onClick) {