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
fb691063
Commit
fb691063
authored
Jun 16, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #887 Enclose embedded images in URLs
parent
796edb03
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
11 deletions
+14
-11
CHANGES.md
CHANGES.md
+1
-0
spec/chatbox.js
spec/chatbox.js
+7
-2
src/utils.js
src/utils.js
+6
-9
No files found.
CHANGES.md
View file @
fb691063
...
...
@@ -24,6 +24,7 @@
-
#754 Show unread messages next to roster contacts. [jcbrand]
-
#864 Remove all inline CSS to comply with strict Content-Security-Policy headers [mathiasertl]
-
#873 Inconsistent unread messages count updating [novokrest]
-
#887 Make embedded images clickabe [jcbrand]
-
#890 Message carbons not sent out after reconnection [jcbrand]
-
#894 Room affiliation lost when connection jid and room presence jid are of different case [Rayzen]
...
...
spec/chatbox.js
View file @
fb691063
...
...
@@ -1247,7 +1247,9 @@
},
500
).
then
(
function
()
{
expect
(
view
.
sendMessage
).
toHaveBeenCalled
();
var
msg
=
view
.
$el
.
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-msg-content
'
);
expect
(
msg
.
html
()).
toEqual
(
'
<img src="
'
+
message
+
'
" class="chat-image">
'
);
expect
(
msg
.
html
()).
toEqual
(
'
<a target="_blank" rel="noopener" href="http://localhost:8000/logo/conversejs.svg"><img src="
'
+
message
+
'
" class="chat-image"></a>
'
);
message
+=
"
?param1=val1¶m2=val2
"
;
test_utils
.
sendMessage
(
view
,
message
);
return
test_utils
.
waitUntil
(
function
()
{
...
...
@@ -1256,7 +1258,10 @@
}).
then
(
function
()
{
expect
(
view
.
sendMessage
).
toHaveBeenCalled
();
var
msg
=
view
.
$el
.
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-msg-content
'
);
expect
(
msg
.
html
()).
toEqual
(
'
<img src="
'
+
message
.
replace
(
/&/g
,
'
&
'
)
+
'
" class="chat-image">
'
);
expect
(
msg
.
html
()).
toEqual
(
'
<a target="_blank" rel="noopener" href="http://localhost:8000/logo/conversejs.svg?param1=val1&param2=val2"><img src="
'
+
message
.
replace
(
/&/g
,
'
&
'
)
+
'
" class="chat-image"></a>
'
)
done
();
});
}));
...
...
src/utils.js
View file @
fb691063
...
...
@@ -94,14 +94,15 @@
return
false
;
};
$
.
fn
.
throttledHTML
=
_
.
throttle
(
$
.
fn
.
html
,
500
);
var
throttledHTML
=
_
.
throttle
(
function
(
el
,
html
)
{
el
.
innerHTML
=
html
;
},
500
);
$
.
fn
.
addHyperlinks
=
function
()
{
if
(
this
.
length
>
0
)
{
this
.
each
(
function
(
i
,
obj
)
{
var
prot
,
escaped_url
;
var
$obj
=
$
(
obj
);
var
x
=
$obj
.
html
();
var
x
=
obj
.
innerHTML
;
var
list
=
x
.
match
(
/
\b(
https
?
:
\/\/
|www
\.
|https
?
:
\/\/
www
\.)[^\s
<
]{2,200}\b
/g
);
if
(
list
)
{
for
(
i
=
0
;
i
<
list
.
length
;
i
++
)
{
...
...
@@ -110,15 +111,11 @@
x
=
x
.
replace
(
list
[
i
],
'
<a target="_blank" rel="noopener" href="
'
+
prot
+
escaped_url
+
'
">
'
+
list
[
i
]
+
'
</a>
'
);
}
}
$obj
.
html
(
x
)
;
obj
.
innerHTML
=
x
;
_
.
forEach
(
list
,
function
(
url
)
{
isImage
(
unescapeHTML
(
url
)).
then
(
function
(
img
)
{
var
prot
=
url
.
indexOf
(
'
http://
'
)
===
0
||
url
.
indexOf
(
'
https://
'
)
===
0
?
''
:
'
http://
'
;
var
escaped_url
=
encodeURI
(
decodeURI
(
url
)).
replace
(
/
[
!'()
]
/g
,
escape
).
replace
(
/
\*
/g
,
"
%2A
"
);
var
new_url
=
'
<a target="_blank" rel="noopener" href="
'
+
prot
+
escaped_url
+
'
">
'
+
url
+
'
</a>
'
;
img
.
className
=
'
chat-image
'
;
x
=
x
.
replace
(
new_url
,
img
.
outerHTML
);
$obj
.
throttledHTML
(
x
);
throttledHTML
(
obj
.
querySelector
(
'
a
'
),
img
.
outerHTML
);
});
});
});
...
...
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