Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match and fix any external id that has escaped forward slashes #1478

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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