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

fix(ios): wkwebview is stripping out = characters in cookies #11286

Merged
merged 4 commits into from
Oct 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions iphone/Classes/TiUIWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -800,17 +800,17 @@ - (void)userContentController:(WKUserContentController *)userContentController d
NSArray<NSString *> *cookies = [message.body componentsSeparatedByString:@"; "];
for (NSString *cookie in cookies) {
// Get this cookie's name and value
NSArray<NSString *> *components = [cookie componentsSeparatedByString:@"="];
if (components.count < 2) {
NSRange separatorRange = [cookie rangeOfString:@"="];
if (separatorRange.location == NSNotFound || separatorRange.location == 0 || separatorRange.location == ([cookie length] - 1)) {
janvennemann marked this conversation as resolved.
Show resolved Hide resolved
continue;
}
NSString *cookieName = [cookie substringToIndex:separatorRange.location];
NSString *cookieValue = [cookie substringFromIndex:separatorRange.location + separatorRange.length];

// Get the cookie in shared storage with that name
NSHTTPCookie *localCookie = nil;
for (NSHTTPCookie *httpCookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:self.webView.URL]) {
NSString *cookieName = httpCookie.name;
NSString *secondComponent = components[0];
if ([cookieName isEqualToString:secondComponent]) {
if ([httpCookie.name isEqualToString:cookieName]) {
localCookie = httpCookie;
break;
}
Expand All @@ -819,7 +819,7 @@ - (void)userContentController:(WKUserContentController *)userContentController d
//If there is a cookie with a stale value, update it now.
if (localCookie != nil) {
NSMutableDictionary *cookieProperties = [localCookie.properties mutableCopy];
cookieProperties[NSHTTPCookieValue] = components[1];
cookieProperties[NSHTTPCookieValue] = cookieValue;
NSHTTPCookie *updatedCookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:updatedCookie];
} else {
Expand Down