Title: [169027] branches/safari-538.34.5-branch/Source/WebKit/mac
Diff
Modified: branches/safari-538.34.5-branch/Source/WebKit/mac/ChangeLog (169026 => 169027)
--- branches/safari-538.34.5-branch/Source/WebKit/mac/ChangeLog 2014-05-19 00:12:32 UTC (rev 169026)
+++ branches/safari-538.34.5-branch/Source/WebKit/mac/ChangeLog 2014-05-19 00:28:41 UTC (rev 169027)
@@ -1,3 +1,20 @@
+2014-05-18 Babak Shafiei <[email protected]>
+
+ Merge r169018
+
+ 2014-05-18 Anders Carlsson <[email protected]>
+
+ Bring back two NSString category methods on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=133055
+ <rdar://problem/16951983>
+
+ Reviewed by Adele Peterson.
+
+ * Misc/WebNSURLExtras.h:
+ * Misc/WebNSURLExtras.mm:
+ (-[NSString _webkit_unescapedQueryValue]):
+ (-[NSString _webkit_queryKeysAndValues]):
+
2014-05-16 Dean Jackson <[email protected]>
Disable some features on the safari-538.34 branch.
Modified: branches/safari-538.34.5-branch/Source/WebKit/mac/Misc/WebNSURLExtras.h (169026 => 169027)
--- branches/safari-538.34.5-branch/Source/WebKit/mac/Misc/WebNSURLExtras.h 2014-05-19 00:12:32 UTC (rev 169026)
+++ branches/safari-538.34.5-branch/Source/WebKit/mac/Misc/WebNSURLExtras.h 2014-05-19 00:28:41 UTC (rev 169027)
@@ -97,4 +97,9 @@
- (NSString *)_webkit_URLFragment;
- (NSString *)_webkit_scriptIfJavaScriptURL;
+#if TARGET_OS_IPHONE
+- (NSString *)_webkit_unescapedQueryValue;
+- (NSDictionary *)_webkit_queryKeysAndValues;
+#endif
+
@end
Modified: branches/safari-538.34.5-branch/Source/WebKit/mac/Misc/WebNSURLExtras.mm (169026 => 169027)
--- branches/safari-538.34.5-branch/Source/WebKit/mac/Misc/WebNSURLExtras.mm 2014-05-19 00:12:32 UTC (rev 169026)
+++ branches/safari-538.34.5-branch/Source/WebKit/mac/Misc/WebNSURLExtras.mm 2014-05-19 00:28:41 UTC (rev 169027)
@@ -396,4 +396,73 @@
return [self substringFromIndex:fragmentRange.location + 1];
}
+#if PLATFORM(IOS)
+
+- (NSString *)_webkit_unescapedQueryValue
+{
+ NSMutableString *string = [[[self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] mutableCopy] autorelease];
+ if (!string) // If we failed to decode the URL as UTF8, fall back to Latin1
+ string = [[[self stringByReplacingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding] mutableCopy] autorelease];
+ [string replaceOccurrencesOfString:@"+" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [string length])];
+ return string;
+}
+
+- (NSDictionary *)_webkit_queryKeysAndValues
+{
+ unsigned queryLength = [self length];
+ if (!queryLength)
+ return nil;
+
+ NSMutableDictionary *queryKeysAndValues = nil;
+ NSRange equalSearchRange = NSMakeRange(0, queryLength);
+
+ while (equalSearchRange.location < queryLength - 1 && equalSearchRange.length) {
+
+ // Search for "=".
+ NSRange equalRange = [self rangeOfString:@"=" options:NSLiteralSearch range:equalSearchRange];
+ if (equalRange.location == NSNotFound)
+ break;
+
+ unsigned indexAfterEqual = equalRange.location + 1;
+ if (indexAfterEqual > queryLength - 1)
+ break;
+
+ // Get the key before the "=".
+ NSRange keyRange = NSMakeRange(equalSearchRange.location, equalRange.location - equalSearchRange.location);
+
+ // Seach for the ampersand.
+ NSRange ampersandSearchRange = NSMakeRange(indexAfterEqual, queryLength - indexAfterEqual);
+ NSRange ampersandRange = [self rangeOfString:@"&" options:NSLiteralSearch range:ampersandSearchRange];
+
+ // Get the value after the "=", before the ampersand.
+ NSRange valueRange;
+ if (ampersandRange.location != NSNotFound)
+ valueRange = NSMakeRange(indexAfterEqual, ampersandRange.location - indexAfterEqual);
+ else
+ valueRange = NSMakeRange(indexAfterEqual, queryLength - indexAfterEqual);
+
+ // Save the key and the value.
+ if (keyRange.length && valueRange.length) {
+ if (queryKeysAndValues == nil)
+ queryKeysAndValues = [NSMutableDictionary dictionary];
+ NSString *key = [[self substringWithRange:keyRange] lowercaseString];
+ NSString *value = [[self substringWithRange:valueRange] _webkit_unescapedQueryValue];
+ if ([key length] && [value length])
+ [queryKeysAndValues setObject:value forKey:key];
+ }
+
+ // At the end.
+ if (ampersandRange.location == NSNotFound)
+ break;
+
+ // Continue searching after the ampersand.
+ unsigned indexAfterAmpersand = ampersandRange.location + 1;
+ equalSearchRange = NSMakeRange(indexAfterAmpersand, queryLength - indexAfterAmpersand);
+ }
+
+ return queryKeysAndValues;
+}
+
+#endif // PLATFORM(IOS)
+
@end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes