From 2dffdf467d6300f43f640a373f9702f9fa42debc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 3 Nov 2015 11:28:13 -0800 Subject: [PATCH] Strip whitespace and newlines from access token and style URL Just in case browser weirdness or a tendency to triple-click-select is causing some cases of #2012. --- platform/ios/MGLAccountManager.m | 2 ++ platform/ios/MGLMapView.mm | 2 ++ 2 files changed, 4 insertions(+) diff --git a/platform/ios/MGLAccountManager.m b/platform/ios/MGLAccountManager.m index d8e445d5ccc..f7b52907674 100644 --- a/platform/ios/MGLAccountManager.m +++ b/platform/ios/MGLAccountManager.m @@ -60,6 +60,8 @@ + (BOOL) mapboxMetricsEnabledSettingShownInApp { } + (void) setAccessToken:(NSString *) accessToken { + accessToken = [accessToken stringByTrimmingCharactersInSet: + [NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ( ! [accessToken length]) return; [MGLAccountManager sharedManager].accessToken = accessToken; diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 078841bbb07..54cc3e879f7 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -3303,6 +3303,8 @@ - (nullable NSString *)styleURL__ - (void)setStyleURL__:(nullable NSString *)URLString { + URLString = [URLString stringByTrimmingCharactersInSet: + [NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSURL *url = URLString.length ? [NSURL URLWithString:URLString] : nil; if (URLString.length && !url) {