summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/Misc
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/Misc')
-rw-r--r--WebKit/mac/Misc/WebDownload.mm5
-rw-r--r--WebKit/mac/Misc/WebNSFileManagerExtras.m12
-rw-r--r--WebKit/mac/Misc/WebNSURLExtras.h11
-rw-r--r--WebKit/mac/Misc/WebNSURLExtras.mm61
4 files changed, 62 insertions, 27 deletions
diff --git a/WebKit/mac/Misc/WebDownload.mm b/WebKit/mac/Misc/WebDownload.mm
index 978465a..01ed767 100644
--- a/WebKit/mac/Misc/WebDownload.mm
+++ b/WebKit/mac/Misc/WebDownload.mm
@@ -31,6 +31,9 @@
#import <Foundation/NSURLAuthenticationChallenge.h>
#import <Foundation/NSURLDownload.h>
#import <WebCore/AuthenticationMac.h>
+#import <WebCore/Credential.h>
+#import <WebCore/CredentialStorage.h>
+#import <WebCore/ProtectionSpace.h>
#import <WebKit/WebPanelAuthenticationHandler.h>
#import <wtf/Assertions.h>
@@ -111,7 +114,7 @@ using namespace WebCore;
{
// Try previously stored credential first.
if (![challenge previousFailureCount]) {
- NSURLCredential *credential = WebCoreCredentialStorage::get([challenge protectionSpace]);
+ NSURLCredential *credential = mac(CredentialStorage::get(core([challenge protectionSpace])));
if (credential) {
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
return;
diff --git a/WebKit/mac/Misc/WebNSFileManagerExtras.m b/WebKit/mac/Misc/WebNSFileManagerExtras.m
index 5733598..fb1286f 100644
--- a/WebKit/mac/Misc/WebNSFileManagerExtras.m
+++ b/WebKit/mac/Misc/WebNSFileManagerExtras.m
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,13 +28,13 @@
#import <WebKit/WebNSFileManagerExtras.h>
+#import "WebKitNSStringExtras.h"
+#import "WebNSURLExtras.h"
#import <WebCore/FoundationExtras.h>
-#import <WebKit/WebKitNSStringExtras.h>
#import <WebKitSystemInterface.h>
-#import <wtf/Assertions.h>
-
#import <pthread.h>
#import <sys/mount.h>
+#import <JavaScriptCore/Assertions.h>
@implementation NSFileManager (WebNSFileManagerExtras)
@@ -170,6 +170,10 @@ static void *setMetaData(void* context)
{
ASSERT(URLString);
ASSERT(path);
+
+ NSURL *URL = [NSURL _web_URLWithUserTypedString:URLString];
+ if (URL)
+ URLString = [[URL _web_URLByRemovingUserInfo] _web_userVisibleString];
// Spawn a background thread for WKSetMetadataURL because this function will not return until mds has
// journaled the data we're're trying to set. Depending on what other I/O is going on, it can take some
diff --git a/WebKit/mac/Misc/WebNSURLExtras.h b/WebKit/mac/Misc/WebNSURLExtras.h
index 40f7cf7..c7b266e 100644
--- a/WebKit/mac/Misc/WebNSURLExtras.h
+++ b/WebKit/mac/Misc/WebNSURLExtras.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,6 +28,9 @@
#import <Foundation/Foundation.h>
+// FIXME: Change method names back to _web_ from _webkit_ when identically-named
+// methods are no longer present in Foundation.
+
@interface NSURL (WebNSURLExtras)
+ (NSURL *)_web_URLWithUserTypedString:(NSString *)string;
@@ -52,12 +55,10 @@
- (BOOL)_web_isEmpty;
-// FIXME: change these names back to _web_ when identically-named
-// methods are removed from Foundation
-
- (NSURL *)_webkit_canonicalize;
- (NSURL *)_webkit_URLByRemovingFragment;
- (NSURL *)_webkit_URLByRemovingResourceSpecifier;
+- (NSURL *)_web_URLByRemovingUserInfo;
- (BOOL)_webkit_isJavaScriptURL;
- (BOOL)_webkit_isFileURL;
@@ -83,8 +84,6 @@
- (NSString *)_web_decodeHostName; // turns funny-looking ASCII form into Unicode, returns self if no decoding needed, convenient cover
- (NSString *)_web_encodeHostName; // turns Unicode into funny-looking ASCII form, returns self if no decoding needed, convenient cover
-// FIXME: change these names back to _web_ when identically-named
-// methods are removed from or renamed in Foundation
- (BOOL)_webkit_isJavaScriptURL;
- (BOOL)_webkit_isFTPDirectoryURL;
- (BOOL)_webkit_isFileURL;
diff --git a/WebKit/mac/Misc/WebNSURLExtras.mm b/WebKit/mac/Misc/WebNSURLExtras.mm
index d956f09..2affbed 100644
--- a/WebKit/mac/Misc/WebNSURLExtras.mm
+++ b/WebKit/mac/Misc/WebNSURLExtras.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
*
* Redistribution and use in source and binary forms, with or without
@@ -619,21 +619,9 @@ static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string)
return result;
}
-typedef struct {
- NSString *scheme;
- NSString *user;
- NSString *password;
- NSString *host;
- CFIndex port; // kCFNotFound means ignore/omit
- NSString *path;
- NSString *query;
- NSString *fragment;
-} WebKitURLComponents;
-
-- (NSURL *)_webkit_URLByRemovingComponent:(CFURLComponentType)component
+- (NSURL *)_web_URLByTruncatingOneCharacterBeforeComponent:(CFURLComponentType)component
{
CFRange fragRg = CFURLGetByteRangeForComponent((CFURLRef)self, component, NULL);
- // Check to see if a fragment exists before decomposing the URL.
if (fragRg.location == kCFNotFound)
return self;
@@ -656,12 +644,53 @@ typedef struct {
- (NSURL *)_webkit_URLByRemovingFragment
{
- return [self _webkit_URLByRemovingComponent:kCFURLComponentFragment];
+ return [self _web_URLByTruncatingOneCharacterBeforeComponent:kCFURLComponentFragment];
}
- (NSURL *)_webkit_URLByRemovingResourceSpecifier
{
- return [self _webkit_URLByRemovingComponent:kCFURLComponentResourceSpecifier];
+ return [self _web_URLByTruncatingOneCharacterBeforeComponent:kCFURLComponentResourceSpecifier];
+}
+
+- (NSURL *)_web_URLByRemovingComponentAndSubsequentCharacter:(CFURLComponentType)component
+{
+ CFRange range = CFURLGetByteRangeForComponent((CFURLRef)self, component, 0);
+ if (range.location == kCFNotFound)
+ return self;
+
+ // Remove one subsequent character.
+ ++range.length;
+
+ UInt8* urlBytes;
+ UInt8 buffer[2048];
+ CFIndex numBytes = CFURLGetBytes((CFURLRef)self, buffer, 2048);
+ if (numBytes == -1) {
+ numBytes = CFURLGetBytes((CFURLRef)self, NULL, 0);
+ urlBytes = static_cast<UInt8*>(malloc(numBytes));
+ CFURLGetBytes((CFURLRef)self, urlBytes, numBytes);
+ } else
+ urlBytes = buffer;
+
+ if (numBytes < range.location)
+ return self;
+ if (numBytes < range.location + range.length)
+ range.length = numBytes - range.location;
+
+ memmove(urlBytes + range.location, urlBytes + range.location + range.length, numBytes - range.location + range.length);
+
+ NSURL *result = (NSURL *)CFMakeCollectable(CFURLCreateWithBytes(NULL, urlBytes, numBytes - range.length, kCFStringEncodingUTF8, NULL));
+ if (!result)
+ result = (NSURL *)CFMakeCollectable(CFURLCreateWithBytes(NULL, urlBytes, numBytes - range.length, kCFStringEncodingISOLatin1, NULL));
+
+ if (urlBytes != buffer)
+ free(urlBytes);
+
+ return result ? [result autorelease] : self;
+}
+
+- (NSURL *)_web_URLByRemovingUserInfo
+{
+ return [self _web_URLByRemovingComponentAndSubsequentCharacter:kCFURLComponentUserInfo];
}
- (BOOL)_webkit_isJavaScriptURL