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
f68eb65c
Commit
f68eb65c
authored
Oct 05, 2020
by
Christoph Scholz
Committed by
JC Brand
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check against own jid when detecting forged mam messages
parent
30d55059
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletion
+55
-1
spec/mam.js
spec/mam.js
+54
-0
src/headless/utils/stanza.js
src/headless/utils/stanza.js
+1
-1
No files found.
spec/mam.js
View file @
f68eb65c
...
...
@@ -265,6 +265,60 @@ describe("Message Archive Management", function () {
done
();
}));
it
(
"
is not discarded if it comes from the right sender
"
,
mock
.
initConverse
(
[
'
discoInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
await
mock
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
await
mock
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
await
mock
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
null
,
[
Strophe
.
NS
.
MAM
]);
const
sent_IQs
=
_converse
.
connection
.
IQ_stanzas
;
const
stanza
=
await
u
.
waitUntil
(()
=>
sent_IQs
.
filter
(
iq
=>
iq
.
querySelector
(
`iq[type="set"] query[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
)).
pop
());
const
queryid
=
stanza
.
querySelector
(
'
query
'
).
getAttribute
(
'
queryid
'
);
let
msg
=
$msg
({
'
id
'
:
_converse
.
connection
.
getUniqueId
(),
'
from
'
:
_converse
.
bare_jid
,
'
to
'
:
_converse
.
bare_jid
})
.
c
(
'
result
'
,
{
'
xmlns
'
:
'
urn:xmpp:mam:2
'
,
'
queryid
'
:
queryid
,
'
id
'
:
_converse
.
connection
.
getUniqueId
()})
.
c
(
'
forwarded
'
,
{
'
xmlns
'
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
delay
'
,
{
'
xmlns
'
:
'
urn:xmpp:delay
'
,
'
stamp
'
:
'
2010-07-10T23:08:25Z
'
}).
up
()
.
c
(
'
message
'
,
{
'
xmlns
'
:
'
jabber:client
'
,
'
to
'
:
_converse
.
bare_jid
,
'
id
'
:
_converse
.
connection
.
getUniqueId
(),
'
from
'
:
contact_jid
,
'
type
'
:
'
chat
'
}).
c
(
'
body
'
).
t
(
"
Meet me at the dance
"
);
spyOn
(
converse
.
env
.
log
,
'
warn
'
);
_converse
.
connection
.
_dataRecv
(
mock
.
createRequest
(
msg
));
msg
=
$msg
({
'
id
'
:
_converse
.
connection
.
getUniqueId
(),
'
to
'
:
_converse
.
bare_jid
})
.
c
(
'
result
'
,
{
'
xmlns
'
:
'
urn:xmpp:mam:2
'
,
'
queryid
'
:
queryid
,
'
id
'
:
_converse
.
connection
.
getUniqueId
()})
.
c
(
'
forwarded
'
,
{
'
xmlns
'
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
delay
'
,
{
'
xmlns
'
:
'
urn:xmpp:delay
'
,
'
stamp
'
:
'
2010-07-10T23:08:25Z
'
}).
up
()
.
c
(
'
message
'
,
{
'
xmlns
'
:
'
jabber:client
'
,
'
to
'
:
_converse
.
bare_jid
,
'
id
'
:
_converse
.
connection
.
getUniqueId
(),
'
from
'
:
contact_jid
,
'
type
'
:
'
chat
'
}).
c
(
'
body
'
).
t
(
"
Thrice the brinded cat hath mew'd.
"
);
_converse
.
connection
.
_dataRecv
(
mock
.
createRequest
(
msg
));
const
iq_result
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
stanza
.
getAttribute
(
'
id
'
)})
.
c
(
'
fin
'
,
{
'
xmlns
'
:
'
urn:xmpp:mam:2
'
})
.
c
(
'
set
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/rsm
'
})
.
c
(
'
first
'
,
{
'
index
'
:
'
0
'
}).
t
(
'
23452-4534-1
'
).
up
()
.
c
(
'
last
'
).
t
(
'
09af3-cc343-b409f
'
).
up
()
.
c
(
'
count
'
).
t
(
'
16
'
);
_converse
.
connection
.
_dataRecv
(
mock
.
createRequest
(
iq_result
));
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
expect
(
view
.
model
.
messages
.
length
).
toBe
(
2
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
message
'
)).
toBe
(
"
Meet me at the dance
"
);
expect
(
view
.
model
.
messages
.
at
(
1
).
get
(
'
message
'
)).
toBe
(
"
Thrice the brinded cat hath mew'd.
"
);
done
();
}));
it
(
"
updates the is_archived value of an already cached version
"
,
mock
.
initConverse
(
...
...
src/headless/utils/stanza.js
View file @
f68eb65c
...
...
@@ -517,7 +517,7 @@ const st = {
if
(
attrs
.
is_archived
)
{
const
from
=
original_stanza
.
getAttribute
(
'
from
'
);
if
(
from
&&
contact_jid
&&
from
!==
contact
_jid
)
{
if
(
from
&&
from
!==
_converse
.
bare
_jid
)
{
return
new
StanzaParseError
(
`Invalid Stanza: Forged MAM message from
${
from
}
`
,
stanza
);
}
}
...
...
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