Commit 75450570b05e2ea8a548715fbd361de92c9e5b23
1 parent
96d3661d08
Exists in
master
Add clean msg from weird chars
Showing 1 changed file with 9 additions and 6 deletions Side-by-side Diff
lib/http-listener.js
... | ... | @@ -49,7 +49,10 @@ function mainHandler(req, res) { |
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | - if (!req.query.msg && !req.body.msg) { | |
52 | + // message cleansing | |
53 | + const msg = (req.query.msg || req.body.msg || '').replace(/[\u{0080}-\u{FFFF}]/gu, '').trim(); | |
54 | + | |
55 | + if (!msg) { | |
53 | 56 | logger.warn('Undefined parameter msg. #92996A497D12') |
54 | 57 | res.end('ERROR. Undefined parameter: msg'); |
55 | 58 | return; |
... | ... | @@ -60,7 +63,7 @@ function mainHandler(req, res) { |
60 | 63 | { |
61 | 64 | transport: req.body.origin_transport || req.query.origin_transport, |
62 | 65 | partner: req.body.partner || req.query.partner || req.body.from || req.query.from || req.body.to || req.query.to, |
63 | - msg: req.body.msg || req.query.msg, | |
66 | + msg, | |
64 | 67 | } |
65 | 68 | ); |
66 | 69 | |
... | ... | @@ -69,7 +72,7 @@ function mainHandler(req, res) { |
69 | 72 | origin_label: req.body.origin_label || req.query.origin_label || req.body.origin || req.query.origin, |
70 | 73 | origin_transport: req.body.origin_transport || req.query.origin_transport, |
71 | 74 | partner: req.body.partner_raw || req.query.partner_raw || req.body.from_raw || req.query.from_raw || req.body.from || req.query.from || req.body.to || req.query.to || req.body.partner || req.query.partner, |
72 | - msg: req.body.msg || req.query.msg, | |
75 | + msg, | |
73 | 76 | }, |
74 | 77 | ( req.body.is_outgoing || req.query.is_outgoing ) ? messagesArchive.DIRECTION_OUTGOING : messagesArchive.DIRECTION_INCOMING |
75 | 78 | ); |
... | ... | @@ -80,7 +83,7 @@ function mainHandler(req, res) { |
80 | 83 | ) { |
81 | 84 | logger.verbose( 'Ignoring message', { |
82 | 85 | from: req.body.from || req.query.from, |
83 | - msg: req.body.msg || req.query.msg, | |
86 | + msg, | |
84 | 87 | do_not_forward_to_core: req.body.do_not_forward_to_core || req.query.do_not_forward_to_core |
85 | 88 | }); |
86 | 89 | |
... | ... | @@ -99,10 +102,10 @@ function mainHandler(req, res) { |
99 | 102 | report_ip: req.body.report_ip || req.query.report_ip || req.ip, |
100 | 103 | report_port: req.body.report_port || req.query.report_port, |
101 | 104 | from: req.body.partner || req.query.partner || req.body.from || req.query.from, |
102 | - msg: req.body.msg || req.query.msg | |
105 | + msg, | |
103 | 106 | } |
104 | 107 | |
105 | - commandHandler(req.body.msg || req.query.msg, params, function(err, coreResponseObject, responseParams) { | |
108 | + commandHandler(msg, params, function(err, coreResponseObject, responseParams) { | |
106 | 109 | if (err) { |
107 | 110 | res.end('ERROR. ' + err); |
108 | 111 | } else if (coreResponseObject) { |