Changeset 49273
- Timestamp:
- 10/07/09 16:20:31 (5 months ago)
- Location:
- trunk/WebKit/mac
- Files:
-
- 4 modified
-
ChangeLog (modified) (1 diff)
-
Misc/WebNSFileManagerExtras.m (modified) (3 diffs)
-
Misc/WebNSURLExtras.h (modified) (4 diffs)
-
Misc/WebNSURLExtras.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/mac/ChangeLog
r49271 r49273 1 2009-10-07 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 Make the setMetadataURL function foolproof by having it remove user info 6 https://bugs.webkit.org/show_bug.cgi?id=30178 7 rdar://problem/6544670 8 9 * Misc/WebNSFileManagerExtras.m: 10 (-[NSFileManager _webkit_setMetadataURL:referrer:atPath:]): 11 Call _web_URLByRemovingUserInfo on the passed in URL string after converting 12 it to a URL, and then convert it back to a string. 13 14 * Misc/WebNSURLExtras.h: Added _web_URLByRemovingUserInfo. 15 * Misc/WebNSURLExtras.mm: Removed unused WebKitURLComponents struct. 16 (-[NSURL _web_URLByTruncatingOneCharacterBeforeComponent:]): Renamed to be 17 clearer on what this does. 18 (-[NSURL _webkit_URLByRemovingFragment]): Changed to call new name. 19 (-[NSURL _webkit_URLByRemovingResourceSpecifier]): Ditto. 20 (-[NSURL _web_URLByRemovingComponentAndSubsequentCharacter:]): Added. 21 (-[NSURL _web_URLByRemovingUserInfo]): Added. 22 1 23 2009-10-07 Simon Fraser <simon.fraser@apple.com> 2 24 -
trunk/WebKit/mac/Misc/WebNSFileManagerExtras.m
r44255 r49273 1 1 /* 2 * Copyright (C) 2005 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #import <WebKit/WebNSFileManagerExtras.h> 30 30 31 #import "WebKitNSStringExtras.h" 32 #import "WebNSURLExtras.h" 31 33 #import <WebCore/FoundationExtras.h> 32 #import <WebKit/WebKitNSStringExtras.h>33 34 #import <WebKitSystemInterface.h> 34 #import <wtf/Assertions.h>35 36 35 #import <pthread.h> 37 36 #import <sys/mount.h> 37 #import <JavaScriptCore/Assertions.h> 38 38 39 39 @implementation NSFileManager (WebNSFileManagerExtras) … … 171 171 ASSERT(URLString); 172 172 ASSERT(path); 173 174 NSURL *URL = [NSURL _web_URLWithUserTypedString:URLString]; 175 if (URL) 176 URLString = [[URL _web_URLByRemovingUserInfo] _web_userVisibleString]; 173 177 174 178 // Spawn a background thread for WKSetMetadataURL because this function will not return until mds has -
trunk/WebKit/mac/Misc/WebNSURLExtras.h
r40346 r49273 1 1 /* 2 * Copyright (C) 2005 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #import <Foundation/Foundation.h> 30 30 31 // FIXME: Change method names back to _web_ from _webkit_ when identically-named 32 // methods are no longer present in Foundation. 33 31 34 @interface NSURL (WebNSURLExtras) 32 35 … … 53 56 - (BOOL)_web_isEmpty; 54 57 55 // FIXME: change these names back to _web_ when identically-named56 // methods are removed from Foundation57 58 58 - (NSURL *)_webkit_canonicalize; 59 59 - (NSURL *)_webkit_URLByRemovingFragment; 60 60 - (NSURL *)_webkit_URLByRemovingResourceSpecifier; 61 - (NSURL *)_web_URLByRemovingUserInfo; 61 62 62 63 - (BOOL)_webkit_isJavaScriptURL; … … 84 85 - (NSString *)_web_encodeHostName; // turns Unicode into funny-looking ASCII form, returns self if no decoding needed, convenient cover 85 86 86 // FIXME: change these names back to _web_ when identically-named87 // methods are removed from or renamed in Foundation88 87 - (BOOL)_webkit_isJavaScriptURL; 89 88 - (BOOL)_webkit_isFTPDirectoryURL; -
trunk/WebKit/mac/Misc/WebNSURLExtras.mm
r45254 r49273 1 1 /* 2 * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 4 4 * … … 620 620 } 621 621 622 typedef struct { 623 NSString *scheme; 624 NSString *user; 625 NSString *password; 626 NSString *host; 627 CFIndex port; // kCFNotFound means ignore/omit 628 NSString *path; 629 NSString *query; 630 NSString *fragment; 631 } WebKitURLComponents; 632 633 - (NSURL *)_webkit_URLByRemovingComponent:(CFURLComponentType)component 622 - (NSURL *)_web_URLByTruncatingOneCharacterBeforeComponent:(CFURLComponentType)component 634 623 { 635 624 CFRange fragRg = CFURLGetByteRangeForComponent((CFURLRef)self, component, NULL); 636 // Check to see if a fragment exists before decomposing the URL.637 625 if (fragRg.location == kCFNotFound) 638 626 return self; … … 657 645 - (NSURL *)_webkit_URLByRemovingFragment 658 646 { 659 return [self _web kit_URLByRemovingComponent:kCFURLComponentFragment];647 return [self _web_URLByTruncatingOneCharacterBeforeComponent:kCFURLComponentFragment]; 660 648 } 661 649 662 650 - (NSURL *)_webkit_URLByRemovingResourceSpecifier 663 651 { 664 return [self _webkit_URLByRemovingComponent:kCFURLComponentResourceSpecifier]; 652 return [self _web_URLByTruncatingOneCharacterBeforeComponent:kCFURLComponentResourceSpecifier]; 653 } 654 655 - (NSURL *)_web_URLByRemovingComponentAndSubsequentCharacter:(CFURLComponentType)component 656 { 657 CFRange range = CFURLGetByteRangeForComponent((CFURLRef)self, component, 0); 658 if (range.location == kCFNotFound) 659 return self; 660 661 // Remove one subsequent character. 662 ++range.length; 663 664 UInt8* urlBytes; 665 UInt8 buffer[2048]; 666 CFIndex numBytes = CFURLGetBytes((CFURLRef)self, buffer, 2048); 667 if (numBytes == -1) { 668 numBytes = CFURLGetBytes((CFURLRef)self, NULL, 0); 669 urlBytes = static_cast<UInt8*>(malloc(numBytes)); 670 CFURLGetBytes((CFURLRef)self, urlBytes, numBytes); 671 } else 672 urlBytes = buffer; 673 674 if (numBytes < range.location) 675 return self; 676 if (numBytes < range.location + range.length) 677 range.length = numBytes - range.location; 678 679 memmove(urlBytes + range.location, urlBytes + range.location + range.length, numBytes - range.location + range.length); 680 681 NSURL *result = (NSURL *)CFMakeCollectable(CFURLCreateWithBytes(NULL, urlBytes, numBytes - range.length, kCFStringEncodingUTF8, NULL)); 682 if (!result) 683 result = (NSURL *)CFMakeCollectable(CFURLCreateWithBytes(NULL, urlBytes, numBytes - range.length, kCFStringEncodingISOLatin1, NULL)); 684 685 if (urlBytes != buffer) 686 free(urlBytes); 687 688 return result ? [result autorelease] : self; 689 } 690 691 - (NSURL *)_web_URLByRemovingUserInfo 692 { 693 return [self _web_URLByRemovingComponentAndSubsequentCharacter:kCFURLComponentUserInfo]; 665 694 } 666 695