Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88f416e

Browse files
committed
Release 4.9.1
1 parent e65ccb2 commit 88f416e

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

SensorsAnalyticsSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "SensorsAnalyticsSDK"
3-
s.version = "4.9.0"
3+
s.version = "4.9.1"
44
s.summary = "The official iOS SDK of Sensors Analytics."
55
s.homepage = "http://www.sensorsdata.cn"
66
s.source = { :git => 'https://github.com/sensorsdata/sa-sdk-ios.git', :tag => "v#{s.version}" }

SensorsAnalyticsSDK/Core/Interceptor/Flush/SAFlushHTTPBodyInterceptor.m

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ - (NSData *)buildBodyWithInput:(SAFlowData *)input {
4444
if (!data) {
4545
return nil;
4646
}
47-
data = [data stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
47+
48+
// data = [data stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
49+
// FIXME: https://github.com/sensorsdata/sa-sdk-ios/issues/148、https://github.com/sensorsdata/sa-sdk-ios/issues/149
50+
data = [self percentEncodingStringFromString:data];
51+
4852
NSString *bodyString = [NSString stringWithFormat:@"crc=%d&gzip=%d&data_list=%@", hashCode, [gzip intValue], data];
4953
if (input.isInstantEvent) {
5054
bodyString = [bodyString stringByAppendingString:@"&instant_event=true"];
@@ -71,4 +75,33 @@ - (NSDictionary *)buildBodyWithFlowData:(SAFlowData *)flowData {
7175
return bodyDic;
7276
}
7377

78+
// 参照 https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFURLRequestSerialization.m
79+
- (NSString *) percentEncodingStringFromString:(NSString *)string {
80+
static NSString * const kSACharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4
81+
static NSString * const kSACharactersSubDelimitersToEncode = @"!$&'()*+,;=";
82+
83+
NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy];
84+
[allowedCharacterSet removeCharactersInString:[kSACharactersGeneralDelimitersToEncode stringByAppendingString:kSACharactersSubDelimitersToEncode]];
85+
86+
static NSUInteger const batchSize = 50;
87+
88+
NSUInteger index = 0;
89+
NSMutableString *escaped = @"".mutableCopy;
90+
91+
while (index < string.length) {
92+
NSUInteger length = MIN(string.length - index, batchSize);
93+
NSRange range = NSMakeRange(index, length);
94+
95+
// To avoid breaking up character sequences such as 👴🏻👮🏽
96+
range = [string rangeOfComposedCharacterSequencesForRange:range];
97+
98+
NSString *substring = [string substringWithRange:range];
99+
NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
100+
[escaped appendString:encoded];
101+
102+
index += range.length;
103+
}
104+
105+
return escaped;
106+
}
74107
@end

SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#import <UIKit/UIApplication.h>
5757
#endif
5858

59-
#define VERSION @"4.9.0"
59+
#define VERSION @"4.9.1"
6060

6161
void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;
6262

0 commit comments

Comments
 (0)