Revision: 2641
http://skim-app.svn.sourceforge.net/skim-app/?rev=2641&view=rev
Author: hofman
Date: 2007-08-13 07:48:43 -0700 (Mon, 13 Aug 2007)
Log Message:
-----------
Clean string for URL or path from pasteboard.
Modified Paths:
--------------
trunk/SKDocumentController.m
trunk/SKDownloadController.m
Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m 2007-08-12 23:12:01 UTC (rev 2640)
+++ trunk/SKDocumentController.m 2007-08-13 14:48:43 UTC (rev 2641)
@@ -174,10 +174,16 @@
} else if ([pboardType isEqualToString:SKWeblocFilePboardType]) {
theURL = [NSURL URLWithString:[pboard
stringForType:SKWeblocFilePboardType]];
} else if ([pboardType isEqualToString:NSStringPboardType]) {
- NSString *string = [pboard stringForType:NSStringPboardType];
+ NSString *string = [[pboard stringForType:NSStringPboardType]
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]];
+ if ([string hasPrefix:@"<"] && [string hasSuffix:@">"])
+ string = [string substringWithRange:NSMakeRange(1, [string
length] - 2)];
theURL = [NSURL URLWithString:string];
- if (theURL == nil && [[NSFileManager defaultManager]
fileExistsAtPath:string])
- theURL = [NSURL fileURLWithPath:string];
+ if (theURL == nil) {
+ if ([string hasPrefix:@"~"])
+ string = [string stringByExpandingTildeInPath];
+ if ([[NSFileManager defaultManager] fileExistsAtPath:string])
+ theURL = [NSURL fileURLWithPath:string];
+ }
}
if ([theURL isFileURL]) {
document = [self openDocumentWithContentsOfURL:theURL display:YES
error:outError];
Modified: trunk/SKDownloadController.m
===================================================================
--- trunk/SKDownloadController.m 2007-08-12 23:12:01 UTC (rev 2640)
+++ trunk/SKDownloadController.m 2007-08-13 14:48:43 UTC (rev 2641)
@@ -205,10 +205,16 @@
} else if ([type isEqualToString:SKWeblocFilePboardType]) {
theURL = [NSURL URLWithString:[pboard
stringForType:SKWeblocFilePboardType]];
} else if ([type isEqualToString:NSStringPboardType]) {
- NSString *string = [pboard stringForType:NSStringPboardType];
+ NSString *string = [[pboard stringForType:NSStringPboardType]
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]];
+ if ([string hasPrefix:@"<"] && [string hasSuffix:@">"])
+ string = [string substringWithRange:NSMakeRange(1, [string length]
- 2)];
theURL = [NSURL URLWithString:string];
- if (theURL == nil && [[NSFileManager defaultManager]
fileExistsAtPath:string])
- theURL = [NSURL fileURLWithPath:string];
+ if (theURL == nil) {
+ if ([string hasPrefix:@"~"])
+ string = [string stringByExpandingTildeInPath];
+ if ([[NSFileManager defaultManager] fileExistsAtPath:string])
+ theURL = [NSURL fileURLWithPath:string];
+ }
}
if ([theURL isFileURL]) {
if ([[NSDocumentController sharedDocumentController]
openDocumentWithContentsOfURL:theURL display:YES error:NULL])
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit