From 3713283edbe3d2205af8719aea208f82c762f50a Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Thu, 23 Apr 2020 18:07:09 +0000 Subject: [PATCH] fix incorrect split to add a limit; fixes 75d0c17 We discovered this while testing message delivery receipts, which fortunately included the word "Gajim" in the messages in our tests, causing Goliath to bail with an HTTP 400 error, indicating bad JSON. Which was correct, since we would only have been sending the JSON part before the 'G' in Gajim, due to incorrectly failing to limit the number of splits being done by the split that is fixed here. That will teach me to parse JSON without a JSON parser, or not... --- r2s-bwmsgsv2.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r2s-bwmsgsv2.rb b/r2s-bwmsgsv2.rb index 4f141d3f0ae1b8af50b4fe1427dc9aa60198e9f2..ab36bf7d4730654f7c7cd702be53afa8d85c470f 100755 --- a/r2s-bwmsgsv2.rb +++ b/r2s-bwmsgsv2.rb @@ -91,7 +91,7 @@ while true uri = URI("http://#{ARGV[1]}:#{ARGV[2]}/") req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') - req.body = new_json_blob.split('G')[1][2..-1] # only use MSG part + req.body = new_json_blob.split('G', 2)[1][2..-1] # only use MSG part begin res = Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(req)