Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
03f9eb95
Commit
03f9eb95
authored
Mar 27, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1467. Fix rendering of URLs enclosed with sharp brackets
such as <
https://example.org
>
parent
cbc34311
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
39 deletions
+115
-39
CHANGES.md
CHANGES.md
+1
-0
dist/converse.js
dist/converse.js
+71
-35
spec/messages.js
spec/messages.js
+11
-2
src/converse-message-view.js
src/converse-message-view.js
+32
-1
src/utils/html.js
src/utils/html.js
+0
-1
No files found.
CHANGES.md
View file @
03f9eb95
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
-
#1407: Silent errors when trying to use whitespace as MUC nickname
-
#1407: Silent errors when trying to use whitespace as MUC nickname
-
#1437: List of groupchats in modal doesn't scroll
-
#1437: List of groupchats in modal doesn't scroll
-
#1457: Wrong tooltip shown for "unbookmark" icon
-
#1457: Wrong tooltip shown for "unbookmark" icon
-
#1467: Fix rendering of URLs enclosed with sharp brackets such as
<https://example.org>
-
#1479: Allow file upload by drag & drop also in MUCs
-
#1479: Allow file upload by drag & drop also in MUCs
-
#1487: New config option
[
muc_respect_autojoin
](
https://conversejs.org/docs/html/configuration.html#muc-respect-autojoin
)
-
#1487: New config option
[
muc_respect_autojoin
](
https://conversejs.org/docs/html/configuration.html#muc-respect-autojoin
)
-
#1501: Don't prompt for a reason if
[
auto_join_on_invite
](
https://conversejs.org/docs/html/configuration.html#auto-join-on-invite
)
is
`true`
-
#1501: Don't prompt for a reason if
[
auto_join_on_invite
](
https://conversejs.org/docs/html/configuration.html#auto-join-on-invite
)
is
`true`
...
...
dist/converse.js
View file @
03f9eb95
This diff is collapsed.
Click to expand it.
spec/messages.js
View file @
03f9eb95
...
@@ -897,12 +897,21 @@
...
@@ -897,12 +897,21 @@
expect
(
msg
.
textContent
).
toEqual
(
message
);
expect
(
msg
.
textContent
).
toEqual
(
message
);
expect
(
msg
.
innerHTML
).
toEqual
(
'
<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Ender%27s_Game">
'
+
message
+
'
</a>
'
);
expect
(
msg
.
innerHTML
).
toEqual
(
'
<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Ender%27s_Game">
'
+
message
+
'
</a>
'
);
message
=
"
https://en.wikipedia.org/wiki/Ender's_Game
"
;
message
=
"
<https://bugs.documentfoundation.org/show_bug.cgi?id=123737>
"
;
await
test_utils
.
sendMessage
(
view
,
message
);
await
test_utils
.
sendMessage
(
view
,
message
);
msg
=
sizzle
(
'
.chat-content .chat-msg:last .chat-msg__text
'
,
view
.
el
).
pop
();
msg
=
sizzle
(
'
.chat-content .chat-msg:last .chat-msg__text
'
,
view
.
el
).
pop
();
expect
(
msg
.
textContent
).
toEqual
(
message
);
expect
(
msg
.
textContent
).
toEqual
(
message
);
expect
(
msg
.
innerHTML
).
toEqual
(
'
<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Ender%27s_Game">
'
+
message
+
'
</a>
'
);
expect
(
msg
.
innerHTML
).
toEqual
(
`<<a target="_blank" rel="noopener" href="https://bugs.documentfoundation.org/show_bug.cgi?id=123737">https://bugs.documentfoundation.org/show_bug.cgi?id=123737</a>>`
);
message
=
'
<http://www.opkode.com/"onmouseover="alert(1)"whatever>
'
;
await
test_utils
.
sendMessage
(
view
,
message
);
msg
=
sizzle
(
'
.chat-content .chat-msg:last .chat-msg__text
'
,
view
.
el
).
pop
();
expect
(
msg
.
textContent
).
toEqual
(
message
);
expect
(
msg
.
innerHTML
).
toEqual
(
'
<<a target="_blank" rel="noopener" href="http://www.opkode.com/%22onmouseover=%22alert%281%29%22whatever">http://www.opkode.com/"onmouseover="alert(1)"whatever</a>>
'
);
done
();
done
();
}));
}));
...
...
src/converse-message-view.js
View file @
03f9eb95
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
// Copyright (c) 2013-2019, the Converse.js developers
// Copyright (c) 2013-2019, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2)
// Licensed under the Mozilla Public License (MPLv2)
import
URI
from
"
urijs
"
;
import
converse
from
"
@converse/headless/converse-core
"
;
import
converse
from
"
@converse/headless/converse-core
"
;
import
filesize
from
"
filesize
"
;
import
filesize
from
"
filesize
"
;
import
html
from
"
./utils/html
"
;
import
html
from
"
./utils/html
"
;
...
@@ -30,6 +31,36 @@ converse.plugins.add('converse-message-view', {
...
@@ -30,6 +31,36 @@ converse.plugins.add('converse-message-view', {
{
__
}
=
_converse
;
{
__
}
=
_converse
;
function
onTagFoundDuringXSSFilter
(
tag
,
html
,
options
)
{
/* This function gets called by the XSS library whenever it finds
* what it thinks is a new HTML tag.
*
* It thinks that something like <https://example.com> is an HTML
* tag and then escapes the <> chars.
*
* We want to avoid this, because it prevents these URLs from being
* shown properly (whithout the trailing >).
*
* The URI lib correctly trims a trailing >, but not a trailing >
*/
if
(
options
.
isClosing
)
{
// Closing tags don't match our use-case
return
;
}
const
uri
=
new
URI
(
tag
);
const
protocol
=
uri
.
protocol
().
toLowerCase
();
if
(
!
_
.
includes
([
"
https
"
,
"
http
"
,
"
xmpp
"
,
"
ftp
"
],
protocol
))
{
// Not a URL, the tag will get filtered as usual
return
;
}
if
(
uri
.
equals
(
tag
)
&&
`<
${
tag
}
>`
===
html
.
toLocaleLowerCase
())
{
// We have something like <https://example.com>, and don't want
// to filter it.
return
html
;
}
}
_converse
.
api
.
settings
.
update
({
_converse
.
api
.
settings
.
update
({
'
show_images_inline
'
:
true
'
show_images_inline
'
:
true
});
});
...
@@ -146,7 +177,7 @@ converse.plugins.add('converse-message-view', {
...
@@ -146,7 +177,7 @@ converse.plugins.add('converse-message-view', {
if
(
is_me_message
)
{
if
(
is_me_message
)
{
text
=
text
.
substring
(
4
);
text
=
text
.
substring
(
4
);
}
}
text
=
xss
.
filterXSS
(
text
,
{
'
whiteList
'
:
{}});
text
=
xss
.
filterXSS
(
text
,
{
'
whiteList
'
:
{}
,
'
onTag
'
:
onTagFoundDuringXSSFilter
});
msg_content
.
innerHTML
=
_
.
flow
(
msg_content
.
innerHTML
=
_
.
flow
(
_
.
partial
(
u
.
geoUriToHttp
,
_
,
_converse
.
geouri_replacement
),
_
.
partial
(
u
.
geoUriToHttp
,
_
,
_converse
.
geouri_replacement
),
_
.
partial
(
u
.
addMentionsMarkup
,
_
,
this
.
model
.
get
(
'
references
'
),
this
.
model
.
collection
.
chatbox
),
_
.
partial
(
u
.
addMentionsMarkup
,
_
,
this
.
model
.
get
(
'
references
'
),
this
.
model
.
collection
.
chatbox
),
...
...
src/utils/html.js
View file @
03f9eb95
...
@@ -138,7 +138,6 @@ u.renderFileURL = function (_converse, url) {
...
@@ -138,7 +138,6 @@ u.renderFileURL = function (_converse, url) {
})
})
};
};
u
.
renderImageURL
=
function
(
_converse
,
url
)
{
u
.
renderImageURL
=
function
(
_converse
,
url
)
{
if
(
!
_converse
.
show_images_inline
)
{
if
(
!
_converse
.
show_images_inline
)
{
return
u
.
addHyperlinks
(
url
);
return
u
.
addHyperlinks
(
url
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment