Software / code / prosody
Comparison
plugins/mod_c2s.lua @ 10379:b917602eac04
mod_c2s: Validate that a 'to' attribute exists at all
Prevents traceback from nameprep(nil)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 02 Nov 2019 15:39:40 +0100 |
| parent | 10226:77f900bbbf25 |
| child | 10465:09697a673015 |
comparison
equal
deleted
inserted
replaced
| 10378:04c4750ff8d2 | 10379:b917602eac04 |
|---|---|
| 54 --- Stream events handlers | 54 --- Stream events handlers |
| 55 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; | 55 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; |
| 56 | 56 |
| 57 function stream_callbacks.streamopened(session, attr) | 57 function stream_callbacks.streamopened(session, attr) |
| 58 local send = session.send; | 58 local send = session.send; |
| 59 if not attr.to then | |
| 60 session:close{ condition = "improper-addressing", | |
| 61 text = "A 'to' attribute is required on stream headers" }; | |
| 62 return; | |
| 63 end | |
| 59 local host = nameprep(attr.to); | 64 local host = nameprep(attr.to); |
| 60 if not host then | 65 if not host then |
| 61 session:close{ condition = "improper-addressing", | 66 session:close{ condition = "improper-addressing", |
| 62 text = "A valid 'to' attribute is required on stream headers" }; | 67 text = "A valid 'to' attribute is required on stream headers" }; |
| 63 return; | 68 return; |