Revision: 24454 http://sourceforge.net/p/bibdesk/svn/24454 Author: hofman Date: 2019-12-11 15:01:46 +0000 (Wed, 11 Dec 2019) Log Message: ----------- check for prism XML using regex, allow RSS document
Modified Paths: -------------- trunk/bibdesk/BDSKPRISMParser.m Modified: trunk/bibdesk/BDSKPRISMParser.m =================================================================== --- trunk/bibdesk/BDSKPRISMParser.m 2019-12-11 14:25:43 UTC (rev 24453) +++ trunk/bibdesk/BDSKPRISMParser.m 2019-12-11 15:01:46 UTC (rev 24454) @@ -39,21 +39,14 @@ #import "BDSKPRISMParser.h" #import "BibItem.h" #import "BDSKStringConstants.h" +#import <AGRegex/AGRegex.h> @implementation BDSKPRISMParser + (BOOL)canParseString:(NSString *)string { - NSUInteger s = NSMaxRange([string rangeOfString:@"<rdf:RDF " options:NSCaseInsensitiveSearch]); - if (s == NSNotFound) - return NO; - NSRange r = NSMakeRange(s, [string length] - s); - NSUInteger e = [string rangeOfString:@">" options:NSCaseInsensitiveSearch range:r].location; - if (e == NSNotFound) - return NO; - r = NSMakeRange(s, e - s); - return (NSNotFound != [string rangeOfString:@"xmlns:prism=\"http://prismstandard.org/namespaces/basic/" options:NSCaseInsensitiveSearch range:r].location && - NSNotFound != [string rangeOfString:@"xmlns:dc=\"http://purl.org/dc/elements/" options:NSCaseInsensitiveSearch range:r].location); + AGRegex *regex = [AGRegex regexWithPattern:@"(<\\?xml[^>]*\\?>\\s*)+<(rdf:RDF|rss) [^>]*xmlns:(prism=\"http://prismstandard\\.org/namespaces/basic|dc=\"http://purl\\.org/dc/elements)/[0-9.]+/\""]; + return nil != [regex findInString:string]; } static NSArray *getProperties(NSXMLNode *node, NSString *key) { @@ -93,7 +86,7 @@ [authors addObjectsFromArray:getProperties(node, @"dc:creator")]; [authors addObjectsFromArray:getProperties(node, @"dc:contributor")]; if ([authors count] == 0) - [authors addObjectsFromArray:getProperties(node, @"authors")]; + [authors addObjectsFromArray:getProperties(node, @"author")]; if ([array count]) [pubDict setObject:[[[authors componentsJoinedByString:@", "] componentsSeparatedByString:@", "] componentsJoinedByString:@" and "] forKey:BDSKAuthorString]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit