Compare View

switch
from
...
to
 
Commits (4)

Changes

Showing 5 changed files Side-by-side Diff

... ... @@ -0,0 +1,5 @@
  1 +# KOMODO CENTER MESSAGING
  2 +
  3 +Center yang merupakan mediator dari center-center KOMODO lain yang berbasis MESSAGING.
  4 +
  5 +(c) [PT TEKNOLOGI TRANSAKSI DIGITAL (TEKTRANS)](https://tektrans.id) 2019
0 6 \ No newline at end of file
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) {
1 1 {
2 2 "name": "komodo-center-messaging",
3   - "version": "0.14.5",
  3 + "version": "0.14.6",
4 4 "lockfileVersion": 1,
5 5 "requires": true,
6 6 "dependencies": {
1 1 {
2 2 "name": "komodo-center-messaging",
3   - "version": "0.14.5",
  3 + "version": "0.14.6",
4 4 "description": "Komodo Common Messaging Center",
5 5 "main": "index.js",
6 6 "scripts": {