General .url robustification. Patches by Wevah <mozilla@derailer.org>. r=pretty much anybody who's reviewed a camino patch.
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_0_BRANCH@217010 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -586,10 +586,11 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
||||
+(NSURL*) decodeLocalFileURL:(NSURL*)url
|
||||
{
|
||||
NSString *urlPathString = [url path];
|
||||
NSString *ext = [[urlPathString pathExtension] lowercaseString];
|
||||
|
||||
if ([[urlPathString pathExtension] isEqualToString:@"url"])
|
||||
if ([ext isEqualToString:@"url"])
|
||||
url = [NSURL urlFromIEURLFile:urlPathString];
|
||||
else if ([[urlPathString pathExtension] isEqualToString:@"webloc"])
|
||||
else if ([ext isEqualToString:@"webloc"])
|
||||
url = [NSURL urlFromWebloc:urlPathString];
|
||||
|
||||
return url;
|
||||
|
||||
@@ -1427,7 +1427,7 @@ static BookmarkManager* gBookmarkManager = nil;
|
||||
NSUndoManager *undoManager = [self undoManager];
|
||||
[undoManager beginUndoGrouping];
|
||||
BOOL success = NO;
|
||||
NSString *extension =[pathToFile pathExtension];
|
||||
NSString *extension = [[pathToFile pathExtension] lowercaseString];
|
||||
if ([extension isEqualToString:@""]) // we'll go out on a limb here
|
||||
success = [self readOperaFile:pathToFile intoFolder:aFolder];
|
||||
else if ([extension isEqualToString:@"html"] || [extension isEqualToString:@"htm"])
|
||||
|
||||
@@ -153,7 +153,7 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
|
||||
*outTitles = [NSMutableArray arrayWithCapacity:[files count]];
|
||||
for ( unsigned int i = 0; i < [files count]; ++i ) {
|
||||
NSString *file = [files objectAtIndex:i];
|
||||
NSString *ext = [file pathExtension];
|
||||
NSString *ext = [[file pathExtension] lowercaseString];
|
||||
NSString *urlString = nil;
|
||||
NSString *title = @"";
|
||||
|
||||
@@ -164,7 +164,7 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
|
||||
urlString = [urlFromWebloc absoluteString];
|
||||
title = [[file lastPathComponent] stringByDeletingPathExtension];
|
||||
}
|
||||
} else if ([ext isEqualToString:@"url"]) {
|
||||
} else if ([ext isEqualToString:@"url"]) {
|
||||
NSURL* urlFromIEURLFile = [NSURL urlFromIEURLFile:file];
|
||||
if (urlFromIEURLFile) {
|
||||
urlString = [urlFromIEURLFile absoluteString];
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Josh Aas - josha@mac.com
|
||||
* Nate Weaver (Wevah) - wevah@derailer.org
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Josh Aas - josha@mac.com
|
||||
* Nate Weaver (Wevah) - wevah@derailer.org
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
@@ -44,6 +43,7 @@
|
||||
//
|
||||
// Reads the URL from a .webloc file.
|
||||
// Returns the URL, or nil on failure.
|
||||
//
|
||||
+(NSURL*)urlFromWebloc:(NSString*)inFile
|
||||
{
|
||||
FSRef ref;
|
||||
@@ -91,12 +91,24 @@
|
||||
if (inFile) {
|
||||
NSCharacterSet *newlines = [NSCharacterSet characterSetWithCharactersInString:@"\r\n"];
|
||||
NSScanner *scanner = [NSScanner scannerWithString:[NSString stringWithContentsOfFile:inFile]];
|
||||
NSString *urlString;
|
||||
[scanner scanUpToString:@"[InternetShortcut]" intoString:nil];
|
||||
|
||||
if ([scanner scanString:@"[InternetShortcut]" intoString:nil] &&
|
||||
[scanner scanString:@"URL=" intoString:nil] &&
|
||||
[scanner scanUpToCharactersFromSet:newlines intoString:&urlString])
|
||||
ret = [NSURL URLWithString:urlString];
|
||||
if ([scanner scanString:@"[InternetShortcut]" intoString:nil]) {
|
||||
// Scan each non-empty line in this section. We don't need to explicitly scan the newlines or
|
||||
// whitespace because NSScanner ignores these by default.
|
||||
NSString *line;
|
||||
|
||||
while ([scanner scanUpToCharactersFromSet:newlines intoString:&line]) {
|
||||
if ([line hasPrefix:@"URL="]) {
|
||||
ret = [NSURL URLWithString:[line substringFromIndex:4]];
|
||||
break;
|
||||
}
|
||||
else if ([line hasPrefix:@"["]) {
|
||||
// This is the start of a new section, so if we haven't found an URL yet, we should bail.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user