Skip to content

Commit

Permalink
Merge pull request #1478 from OneSignal/fix/unescapeEID
Browse files Browse the repository at this point in the history
Match and fix any external id that has escaped forward slashes
  • Loading branch information
jkasten2 committed Nov 5, 2021
2 parents 6445171 + a72bb20 commit dbed822
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class OneSignalRestClient {
static abstract class ResponseHandler {
Expand Down Expand Up @@ -158,6 +160,18 @@ private static Thread startHTTPConnection(String url, String method, JSONObject

if (jsonBody != null) {
String strJsonBody = jsonBody.toString();

Pattern eidPattern = Pattern.compile("(?<=\"external_user_id\":\").*\\\\/.*?(?=\",|\"\\})");
Matcher eidMatcher = eidPattern.matcher(strJsonBody);

if (eidMatcher.find()) {
String matched = eidMatcher.group(0);
if (matched != null) {
String unescapedEID = matched.replace("\\/", "/");
strJsonBody = eidMatcher.replaceAll(unescapedEID);
}
}

OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "OneSignalRestClient: " + method + " SEND JSON: " + strJsonBody);

byte[] sendBytes = strJsonBody.getBytes("UTF-8");
Expand Down

0 comments on commit dbed822

Please sign in to comment.