Revision: 29199
http://sourceforge.net/p/bibdesk/svn/29199
Author: hofman
Date: 2025-04-26 13:51:48 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Don't percent-escape forward slash in database, move header to Headers
Modified Paths:
--------------
trunk/bibdesk/BDSKSRUGroupServer.m
trunk/bibdesk/BDSKServerInfo.m
trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
Modified: trunk/bibdesk/BDSKSRUGroupServer.m
===================================================================
--- trunk/bibdesk/BDSKSRUGroupServer.m 2025-04-25 22:25:32 UTC (rev 29198)
+++ trunk/bibdesk/BDSKSRUGroupServer.m 2025-04-26 13:51:48 UTC (rev 29199)
@@ -44,7 +44,7 @@
#import "NSURL_BDSKExtensions.h"
#define MAX_RESULTS 100
-#define MAX_TOTAL_RESULTS 1000
+#define MAX_TOTAL_RESULTS 100
enum { BDSKIdleState, BDSKSearchState, BDSKFetchState };
@@ -86,6 +86,45 @@
return self;
}
+#pragma mark URLs
+
+- (NSURLComponents *)baseURLComponents {
+ NSString *host = [[[self serverInfo] host]
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet
URLHostAllowedCharacterSet]];
+ NSInteger port = [[[self serverInfo] port] integerValue];
+ NSString *database = [[[self serverInfo] database]
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet
URLPathAllowedCharacterSet]];
+ NSURLComponents *components = [[NSURLComponents alloc] init];
+ [components setScheme:@"http"];
+ [components setPercentEncodedHost:host];
+ if (port > 0)
+ [components setPort:[NSNumber numberWithInteger:port]];
+ [components setPercentEncodedPath:[@"/" stringByAppendingString:database]];
+ return components;
+}
+
+- (NSURL *)searchURL {
+ NSURLComponents *components = [self baseURLComponents];
+ NSMutableArray *query = [NSMutableArray array];
+ NSString *version = [[[self serverInfo] options] objectForKey:@"version"]
?: @"1.1";
+ [query addObject:[@"version=" stringByAppendingString:version]];
+ [query addObject:@"operation=searchRetrieve"];
+ [query addObject:[@"query=" stringByAppendingString:[[self searchTerm]
stringByAddingPercentEscapesForQueryTerm]]];
+ [components setPercentEncodedQuery:[query componentsJoinedByString:@"&"]];
+ return [components URL];
+}
+
+- (NSURL *)fetchURL {
+ NSURLComponents *components = [self baseURLComponents];
+ NSMutableArray *query = [NSMutableArray array];
+ NSString *version = [[[self serverInfo] options] objectForKey:@"version"]
?: @"1.1";
+ [query addObject:[@"version=" stringByAppendingString:version]];
+ [query addObject:@"operation=searchRetrieve"];
+ [query addObject:[@"query=%@" stringByAppendingString:[[self searchTerm]
stringByAddingPercentEscapesForQueryTerm]]];
+ [query addObject:[NSString stringWithFormat:@"startRecord=%ld", 1 + [self
numberOfFetchedResults]]];
+ [query addObject:[NSString stringWithFormat:@"maximumRecords=%ld",
MIN([self numberOfAvailableResults] - [self numberOfFetchedResults],
MAX_RESULTS)]];
+ [components setPercentEncodedQuery:[query componentsJoinedByString:@"&"]];
+ return [components URL];
+}
+
#pragma mark BDSKSearchGroupServer protocol
- (NSString *)type { return BDSKSearchGroupSRU; }
@@ -104,7 +143,7 @@
}
- (void)retrieveWithSearchTerm:(NSString *)aSearchTerm {
- if ([[[self baseComponents] URL] canConnect]) {
+ if ([[[self baseURLComponents] URL] canConnect]) {
if ([[self searchTerm] isEqualToString:aSearchTerm] == NO ||
needsReset) {
[self setSearchTerm:aSearchTerm];
[self resetSearch];
@@ -137,59 +176,6 @@
- (NSFormatter *)searchStringFormatter { return nil; }
-#pragma mark URLs
-
-static inline NSString *escapeHost(NSString *string) {
- return [string
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet
URLHostAllowedCharacterSet]];
-}
-
-static NSString *escapeDatabase(NSString *string) {
- static NSCharacterSet *URLDatabaseOrNameAllowedCharacterSet = nil;
- if (URLDatabaseOrNameAllowedCharacterSet == nil) {
- NSMutableCharacterSet *tmpSet = [[NSCharacterSet
URLPathAllowedCharacterSet] mutableCopy];
- [tmpSet removeCharactersInString:@"/"];
- URLDatabaseOrNameAllowedCharacterSet = [tmpSet copy];
- }
- return [string
stringByAddingPercentEncodingWithAllowedCharacters:URLDatabaseOrNameAllowedCharacterSet];
-}
-
-- (NSURLComponents *)baseComponents {
- NSString *host = [[self serverInfo] host];
- NSInteger port = [[[self serverInfo] port] integerValue];
- NSString *database = [[self serverInfo] database];
- NSURLComponents *components = [[NSURLComponents alloc] init];
- [components setScheme:@"http"];
- [components setPercentEncodedHost:escapeHost(host)];
- if (port > 0)
- [components setPort:[NSNumber numberWithInteger:port]];
- [components setPercentEncodedPath:[@"/"
stringByAppendingString:escapeDatabase(database)]];
- return components;
-}
-
-- (NSURL *)searchURL {
- NSURLComponents *components = [self baseComponents];
- NSMutableArray *query = [NSMutableArray array];
- NSString *version = [[[self serverInfo] options] objectForKey:@"version"]
?: @"1.1";
- [query addObject:[@"version=" stringByAppendingString:version]];
- [query addObject:@"operation=searchRetrieve"];
- [query addObject:[@"query=" stringByAppendingString:[[self searchTerm]
stringByAddingPercentEscapesForQueryTerm]]];
- [components setPercentEncodedQuery:[query componentsJoinedByString:@"&"]];
- return [components URL];
-}
-
-- (NSURL *)fetchURL {
- NSURLComponents *components = [self baseComponents];
- NSMutableArray *query = [NSMutableArray array];
- NSString *version = [[[self serverInfo] options] objectForKey:@"version"]
?: @"1.1";
- [query addObject:[@"version=" stringByAppendingString:version]];
- [query addObject:@"operation=searchRetrieve"];
- [query addObject:[@"query=%@" stringByAppendingString:[[self searchTerm]
stringByAddingPercentEscapesForQueryTerm]]];
- [query addObject:[NSString stringWithFormat:@"startRecord=%ld", 1 + [self
numberOfFetchedResults]]];
- [query addObject:[NSString stringWithFormat:@"maximumRecords=%ld",
MIN([self numberOfAvailableResults] - [self numberOfFetchedResults],
MAX_RESULTS)]];
- [components setPercentEncodedQuery:[query componentsJoinedByString:@"&"]];
- return [components URL];
-}
-
#pragma mark Search methods
- (void)resetSearch {
@@ -285,8 +271,16 @@
{
NSString *string = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
- NSArray *pubs = [BDSKMARCParser itemsFromString:string
error:&presentableError];
+ NSArray *pubs = nil;
+ if ([BDSKMARCParser canParseString:string]) {
+ pubs = [BDSKMARCParser itemsFromString:string
error:&presentableError];
+ } else {
+ BDSKStringType stringType = [string contentStringType];
+ if (stringType != BDSKStringTypeUnknown)
+ pubs = [BDSKStringParser itemsFromString:string
ofType:stringType error:&presentableError];
+ }
+
// the number of returned results is not always equal to what we
requested
// fetchedResults should track the requests to get the correct
offset
fetchedResults += requestedResults;
@@ -293,7 +287,7 @@
if (nil == pubs) {
failedDownload = YES;
- [self setErrorMessage:[presentableError localizedDescription]];
+ [self setErrorMessage:[presentableError localizedDescription]
?: NSLocalizedString(@"Could not retrieve results", @"")];
// set before addPublications:
downloadState = BDSKIdleState;
[group addPublications:nil];
Modified: trunk/bibdesk/BDSKServerInfo.m
===================================================================
--- trunk/bibdesk/BDSKServerInfo.m 2025-04-25 22:25:32 UTC (rev 29198)
+++ trunk/bibdesk/BDSKServerInfo.m 2025-04-26 13:51:48 UTC (rev 29199)
@@ -334,14 +334,18 @@
return [string
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet
URLHostAllowedCharacterSet]];
}
-static NSString *escapeDatabaseOrName(NSString *string) {
- static NSCharacterSet *URLDatabaseOrNameAllowedCharacterSet = nil;
- if (URLDatabaseOrNameAllowedCharacterSet == nil) {
+static NSString *escapeDatabase(NSString *string) {
+ return [string
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet
URLPathAllowedCharacterSet]];
+}
+
+static NSString *escapeName(NSString *string) {
+ static NSCharacterSet *URLNameAllowedCharacterSet = nil;
+ if (URLNameAllowedCharacterSet == nil) {
NSMutableCharacterSet *tmpSet = [[NSCharacterSet
URLPathAllowedCharacterSet] mutableCopy];
[tmpSet removeCharactersInString:@"/"];
- URLDatabaseOrNameAllowedCharacterSet = [tmpSet copy];
+ URLNameAllowedCharacterSet = [tmpSet copy];
}
- return [string
stringByAddingPercentEncodingWithAllowedCharacters:URLDatabaseOrNameAllowedCharacterSet];
+ return [string
stringByAddingPercentEncodingWithAllowedCharacters:URLNameAllowedCharacterSet];
}
- (NSURL *)URLValue {
@@ -357,7 +361,7 @@
} else {
[components setPercentEncodedHost:[self type]];
}
- [components setPercentEncodedPath:[NSString stringWithFormat:@"/%@;%@",
escapeDatabaseOrName([self database]), escapeDatabaseOrName([self name])]];
+ [components setPercentEncodedPath:[NSString stringWithFormat:@"/%@;%@",
escapeDatabase([self database]), escapeName([self name])]];
if ([self isZoom]) {
NSMutableArray *query = [NSMutableArray array];
[options enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString
*value, BOOL *stop){
Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj 2025-04-25 22:25:32 UTC
(rev 29198)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj 2025-04-26 13:51:48 UTC
(rev 29199)
@@ -1547,8 +1547,8 @@
CE3B682709D1B0190017D339 /* BDSKImagePopUpButton.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKImagePopUpButton.m; sourceTree = "<group>"; };
CE3B682809D1B0190017D339 /* BDSKImagePopUpButtonCell.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = BDSKImagePopUpButtonCell.h; sourceTree = "<group>"; };
CE3B682909D1B0190017D339 /* BDSKImagePopUpButtonCell.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = BDSKImagePopUpButtonCell.m; sourceTree = "<group>"; };
- CE3D27C62DBB85AA002EA644 /* BDSKSRUGroupServer.h */ = {isa =
PBXFileReference; lastKnownFileType = sourcecode.c.h; path =
BDSKSRUGroupServer.h; sourceTree = "<group>"; };
- CE3D27C72DBB85AA002EA644 /* BDSKSRUGroupServer.m */ = {isa =
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path =
BDSKSRUGroupServer.m; sourceTree = "<group>"; };
+ CE3D27C62DBB85AA002EA644 /* BDSKSRUGroupServer.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKSRUGroupServer.h; sourceTree = "<group>"; };
+ CE3D27C72DBB85AA002EA644 /* BDSKSRUGroupServer.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKSRUGroupServer.m; sourceTree = "<group>"; };
CE3D8DA0125E69BB00AE0232 /* de */ = {isa = PBXFileReference;
fileEncoding = 10; lastKnownFileType = text.plist.strings; name = de; path =
de.lproj/BibTeXKeys.strings; sourceTree = "<group>"; };
CE3D8DA5125E69BB00AE0232 /* de */ = {isa = PBXFileReference;
lastKnownFileType = text.rtf; name = de; path = de.lproj/Credits.rtf;
sourceTree = "<group>"; };
CE3D8DA9125E69BB00AE0232 /* de */ = {isa = PBXFileReference;
fileEncoding = 10; lastKnownFileType = text.plist.strings; name = de; path =
de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@@ -3175,7 +3175,6 @@
F94DB0F70B3E2FA1006F37A2 /* BDSKSearchGroup.m
*/,
F92EF32109E6242100A244D0 /* BDSKSharedGroup.m
*/,
CEFDBDBC0AEA86BA009EE99D /* BDSKSmartGroup.m */,
- CE3D27C62DBB85AA002EA644 /*
BDSKSRUGroupServer.h */,
CE3D27C72DBB85AA002EA644 /*
BDSKSRUGroupServer.m */,
CEFDBDC40AEA86F0009EE99D /* BDSKStaticGroup.m
*/,
F9F5ECD00AE5E7C8007EBB31 /* BDSKURLGroup.m */,
@@ -3479,6 +3478,7 @@
CE83E3A30D294EE300BB7AD8 /* BDSKSortCommand.h
*/,
CE62E0910F4C46D600BDF01E /* BDSKSplitView.h */,
CD62952F1140DDDA002E4751 /*
BDSKSpringerParser.h */,
+ CE3D27C62DBB85AA002EA644 /*
BDSKSRUGroupServer.h */,
CEFDBDC30AEA86F0009EE99D /* BDSKStaticGroup.h
*/,
CE30FAD50919713100CB1A19 /* BDSKStatusBar.h */,
CEF5460D0F56BDDB008A630F /*
BDSKStringArrayFormatter.h */,
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