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
ac31d41c
Commit
ac31d41c
authored
Sep 01, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test string value for `filter_url_query_params`
parent
3535d05f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
spec/messages.js
spec/messages.js
+16
-6
No files found.
spec/messages.js
View file @
ac31d41c
...
@@ -898,7 +898,8 @@ describe("A Chat Message", function () {
...
@@ -898,7 +898,8 @@ describe("A Chat Message", function () {
it
(
"
will remove url query parameters from hyperlinks as set
"
,
it
(
"
will remove url query parameters from hyperlinks as set
"
,
mock
.
initConverse
(
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
filter_url_query_params
'
:
[
'
utm_medium
'
,
'
utm_content
'
,
'
s
'
]},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
mock
.
waitForRoster
(
_converse
,
'
current
'
);
await
mock
.
waitForRoster
(
_converse
,
'
current
'
);
...
@@ -906,16 +907,25 @@ describe("A Chat Message", function () {
...
@@ -906,16 +907,25 @@ describe("A Chat Message", function () {
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
await
mock
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
mock
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
_converse
.
api
.
settings
.
set
(
'
filter_url_query_params
'
,
[
'
utm_medium
'
,
'
utm_content
'
,
'
s
'
]);
let
message
=
'
This message contains a hyperlink with forbidden query params: https://www.opkode.com/?id=0&utm_content=1&utm_medium=2&s=1
'
;
const
message
=
'
This message contains a hyperlink with forbidden query params: https://www.opkode.com/?id=0&utm_content=1&utm_medium=2&s=1
'
;
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
mock
.
sendMessage
(
view
,
message
);
mock
.
sendMessage
(
view
,
message
);
expect
(
view
.
model
.
sendMessage
).
toHaveBeenCalled
();
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
cons
t
msg
=
sizzle
(
'
.chat-content .chat-msg:last .chat-msg__text
'
,
view
.
el
).
pop
();
le
t
msg
=
sizzle
(
'
.chat-content .chat-msg:last .chat-msg__text
'
,
view
.
el
).
pop
();
expect
(
msg
.
textContent
).
toEqual
(
message
);
expect
(
msg
.
textContent
).
toEqual
(
message
);
await
u
.
waitUntil
(()
=>
msg
.
innerHTML
.
replace
(
/<!---->/g
,
''
)
===
await
u
.
waitUntil
(()
=>
msg
.
innerHTML
.
replace
(
/<!---->/g
,
''
)
===
'
This message contains a hyperlink with forbidden query params: <a target="_blank" rel="noopener" href="https://www.opkode.com/?id=0">https://www.opkode.com/?id=0</a>
'
);
'
This message contains a hyperlink with forbidden query params: <a target="_blank" rel="noopener" href="https://www.opkode.com/?id=0">https://www.opkode.com/?id=0</a>
'
);
// Test assigning a string to filter_url_query_params
_converse
.
api
.
settings
.
set
(
'
filter_url_query_params
'
,
'
utm_medium
'
);
message
=
'
Another message with a hyperlink with forbidden query params: https://www.opkode.com/?id=0&utm_content=1&utm_medium=2&s=1
'
;
mock
.
sendMessage
(
view
,
message
);
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
msg
=
sizzle
(
'
.chat-content .chat-msg:last .chat-msg__text
'
,
view
.
el
).
pop
();
expect
(
msg
.
textContent
).
toEqual
(
message
);
await
u
.
waitUntil
(()
=>
msg
.
innerHTML
.
replace
(
/<!---->/g
,
''
)
===
'
Another message with a hyperlink with forbidden query params:
'
+
'
<a target="_blank" rel="noopener" href="https://www.opkode.com/?id=0&utm_content=1&s=1">https://www.opkode.com/?id=0&utm_content=1&s=1</a>
'
);
done
();
done
();
}));
}));
...
...
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