From 515d74a1eac3207cc0e7a044919940bde3ca19cd Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 26 Jul 2018 11:26:11 -0600 Subject: [PATCH] fix #29 by uri encoding and decoding json --- bin/telebit.js | 2 +- bin/telebitd.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/telebit.js b/bin/telebit.js index 0606660..92848bd 100755 --- a/bin/telebit.js +++ b/bin/telebit.js @@ -402,7 +402,7 @@ var utils = { var req = http.request({ socketPath: state._ipc.path , method: 'POST' - , path: '/rpc/' + service + '?_body=' + JSON.stringify(args) + , path: '/rpc/' + service + '?_body=' + encodeURIComponent(JSON.stringify(args)) }, function (resp) { function finish() { diff --git a/bin/telebitd.js b/bin/telebitd.js index e85702a..73b0f8e 100755 --- a/bin/telebitd.js +++ b/bin/telebitd.js @@ -278,7 +278,7 @@ function serveControlsHelper() { var opts = url.parse(req.url, true); if (opts.query._body) { try { - opts.body = JSON.parse(opts.query._body, true); + opts.body = JSON.parse(decodeURIComponent(opts.query._body, true)); } catch(e) { res.statusCode = 500; res.end('{"error":{"message":"?_body={{bad_format}}"}}');