File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
iOS_SDK/OneSignalSDK/Source Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -101,16 +101,18 @@ -(void)attachBodyToRequest:(NSMutableURLRequest *)request withParameters:(NSDict
101101 }
102102
103103 NSError *error;
104- if (@available (iOS 13 , *))
105- request.HTTPBody = [NSJSONSerialization dataWithJSONObject: parameters options: NSJSONWritingWithoutEscapingSlashes error: &error];
106- else {
107- NSData * requestData = [NSJSONSerialization dataWithJSONObject: parameters options: 0 error: &error];
108- NSString * requestString = [[NSString alloc ] initWithData: requestData encoding: NSUTF8StringEncoding];
109- requestString = [requestString stringByReplacingOccurrencesOfString: @" \\ /" withString: @" /" ];
110- requestData = [requestString dataUsingEncoding: NSUTF8StringEncoding];
104+ NSData *requestData = [NSJSONSerialization dataWithJSONObject: parameters options: 0 error: &error];
105+ NSString *requestString = [[NSString alloc ] initWithData: requestData encoding: NSUTF8StringEncoding];
111106
112- request.HTTPBody = requestData;
107+ NSRegularExpression *eidRegex = [NSRegularExpression regularExpressionWithPattern: @" (?<=\" external_user_id\" :\" ).*\\ /.*?(?=\" ,|\"\\ })" options: 0 error: &error];
108+ NSArray *matches = [eidRegex matchesInString: requestString options: 0 range: NSMakeRange (0 , [requestString length ])];
109+ for (NSTextCheckingResult *match in matches) {
110+ NSString *matched = [requestString substringWithRange: [match range ]];
111+ NSString *unescapedEID = [matched stringByReplacingOccurrencesOfString: @" \\ /" withString: @" /" ];
112+ requestString = [requestString stringByReplacingOccurrencesOfString: matched withString: unescapedEID];
113113 }
114+
115+ request.HTTPBody = [requestString dataUsingEncoding: NSUTF8StringEncoding];
114116}
115117
116118-(void )attachQueryParametersToRequest : (NSMutableURLRequest *)request withParameters : (NSDictionary *)parameters {
You can’t perform that action at this time.
0 commit comments