Match and fix any external id that has escaped forward slashes#1478
Match and fix any external id that has escaped forward slashes#1478
Conversation
There was a problem hiding this comment.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @adamschlesinger, @emawby, and @jmadler)
OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalRestClient.java, line 164 at r1 (raw file):
String strJsonBody = jsonBody.toString(); Pattern eidPattern = Pattern.compile("(?<=\"external_user_id\":\").*\\\\/.*?(?=\",|\"\\})");
Looks like you have an extra \ on the or operator when looking for }. I believe the full regex should be
(?<=\"external_user_id\":\").*\\\\/.*?(?=\",|\"\})Tested with the following to confirm:
https://regex101.com/r/yAlOnr/1/
OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalRestClient.java, line 167 at r1 (raw file):
Matcher eidMatcher = eidPattern.matcher(strJsonBody); if (eidMatcher.find()) {
We be nice to split this code into it's own descriptive method so we don't have to add the implementation details don't have to live in the startHTTPConnection method itself.
adamschlesinger
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @adamschlesinger, @emawby, @jkasten2, and @jmadler)
OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalRestClient.java, line 164 at r1 (raw file):
Previously, jkasten2 (Josh Kasten) wrote…
Looks like you have an extra
\on the or operator when looking for}. I believe the full regex should be(?<=\"external_user_id\":\").*\\\\/.*?(?=\",|\"\})Tested with the following to confirm:
https://regex101.com/r/yAlOnr/1/
You need to escape the escape for Java.
jkasten2
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @adamschlesinger, @emawby, and @jmadler)
OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalRestClient.java, line 164 at r1 (raw file):
Previously, adamschlesinger (Adam Schlesinger) wrote…
You need to escape the escape for Java.
ah you are right, tested it in Java and you need to have exactly\\} for it to work.
jkasten2
left a comment
There was a problem hiding this comment.
1 comment left, recommended code clean up but not required.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @adamschlesinger, @emawby, and @jmadler)
Fix for https://app.asana.com/0/1193807006058450/1201230887422941/f which explicitly only checks outbound external user ids.
This will NOT prevent the client from saving the EID with escaped slashes. This is why there is no
if (matched != currentEID)check. We cannot rely on the current EID on the client to be unescaped.This change is