bogkonstantin / android_income_sms_gateway_webhook

Simple Android incoming SMS to URL forwarder
MIT License
352 stars 96 forks source link

Fix issues with JSON quoting `%text%` content #34

Closed scottmconway closed 1 year ago

scottmconway commented 1 year ago

I wasn't having luck with the application properly JSON-quoting text message content - this PR fixes that. Also, it makes %text% the final replacement to be done, as the text message could contain references to other attributes that should not be replaced with their values.

bogkonstantin commented 1 year ago

Thanks @scottmconway

sat-neko commented 1 year ago

After I updated to v. 2.2.2 all my Cyrillic SMS are forwarded as Unicode escaped strings, rendering them unreadable (I use ntfy.sh as webhook URL).

Since Cyrillic symbols in JSON template work fine and v. 2.2.1 works fine too. I think this exact change is the root cause of the problem I observe.

scottmconway commented 1 year ago

@sat-neko thanks for the ping - looks like the quoting I introduced was escaping valid \u sequences. The above commit uses org.json.JSONObject's quote method instead. I've tested with unicode sequences, and it works fine.

I'll open another PR shortly.