Revision: 27622
http://sourceforge.net/p/bibdesk/svn/27622
Author: hofman
Date: 2022-06-13 08:38:11 +0000 (Mon, 13 Jun 2022)
Log Message:
-----------
Only allow http(s) URLs for web search in import command
Modified Paths:
--------------
trunk/bibdesk/BibDocument+Scripting.m
Modified: trunk/bibdesk/BibDocument+Scripting.m
===================================================================
--- trunk/bibdesk/BibDocument+Scripting.m 2022-06-13 06:30:19 UTC (rev
27621)
+++ trunk/bibdesk/BibDocument+Scripting.m 2022-06-13 08:38:11 UTC (rev
27622)
@@ -1064,7 +1064,16 @@
[command setScriptErrorNumber:NSArgumentsWrongScriptError];
return nil;
}
- } else if (source && [source isKindOfClass:[NSString class]] == NO &&
[source isKindOfClass:[NSArray class]] == NO) {
+ } else if ([source isKindOfClass:[NSString class]]) {
+ NSURL *aURL = nil;
+ if ([source hasCaseInsensitivePrefix:@"https://"] || [source
hasCaseInsensitivePrefix:@"http://"]) {
+ aURL = [NSURL URLWithString:source];
+ if ([[aURL host] isCaseInsensitiveEqual:@"doi.org"] || [[aURL
host] isCaseInsensitiveEqual:@"dx.doi.org"])
+ aURL = nil;
+ }
+ if (aURL)
+ source = aURL;
+ } else if (source && [source isKindOfClass:[NSArray class]] == NO) {
[command setScriptErrorNumber:NSArgumentsWrongScriptError];
return nil;
}
@@ -1163,19 +1172,11 @@
}
pubs = tmpPubs;
} else if ([source isKindOfClass:[NSString class]]) {
- NSURL *aURL = nil;
- if ([source rangeOfString:@"://"].location != NSNotFound) {
- aURL = [NSURL URLWithString:source];
- if ([[aURL host] isCaseInsensitiveEqual:@"doi.org"] || [[aURL
host] isCaseInsensitiveEqual:@"dx.doi.org"])
- aURL = nil;
- }
- if (aURL) {
- pubs = [BDSKWebSearch itemsFromURL:aURL macroResolver:[self
macroResolver] completionHandler:synchronous ? nil : handler];
- if (synchronous == NO)
- return nil;
- } else {
- pubs = [BDSKStringParser itemsFromString:source
ofType:BDSKStringTypeUnknown owner:self error:NULL];
- }
+ pubs = [BDSKStringParser itemsFromString:source
ofType:BDSKStringTypeUnknown owner:self error:NULL];
+ } else if ([source isKindOfClass:[NSURL class]]) {
+ pubs = [BDSKWebSearch itemsFromURL:source macroResolver:[self
macroResolver] completionHandler:synchronous ? nil : handler];
+ if (synchronous == NO)
+ return nil;
} else if (searchTerm) {
pubs = [BDSKGroupSearch searchUsingSearchTerm:searchTerm
serverInfo:serverInfo macroResolver:[self macroResolver]
completionHandler:synchronous ? nil : handler];
if (synchronous == NO)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit