Revision: 24448 http://sourceforge.net/p/bibdesk/svn/24448 Author: hofman Date: 2019-12-10 22:42:09 +0000 (Tue, 10 Dec 2019) Log Message: ----------- search string instead of using regex
Modified Paths: -------------- trunk/bibdesk/BDSKPRISMParser.m Modified: trunk/bibdesk/BDSKPRISMParser.m =================================================================== --- trunk/bibdesk/BDSKPRISMParser.m 2019-12-10 22:31:48 UTC (rev 24447) +++ trunk/bibdesk/BDSKPRISMParser.m 2019-12-10 22:42:09 UTC (rev 24448) @@ -37,7 +37,6 @@ */ #import "BDSKPRISMParser.h" -#import <AGRegex/AGRegex.h> #import "BibItem.h" #import "BDSKStringConstants.h" @@ -45,11 +44,16 @@ @implementation BDSKPRISMParser + (BOOL)canParseString:(NSString *)string { - AGRegex *regex = [AGRegex regexWithPattern:@"<rdf:RDF [^>]*xmlns:prism=\"http://prismstandard\\.org/namespaces/basic/[0-9.]+/?\""]; - if (nil == [regex findInString:string]) + NSUInteger s = NSMaxRange([string rangeOfString:@"<rdf:RDF " options:NSCaseInsensitiveSearch]); + if (s == NSNotFound) return NO; - regex = [AGRegex regexWithPattern:@"<rdf:RDF [^>]*xmlns:dc=\"http://purl\\.org/dc/elements/[0-9.]+/?\""]; - return nil != [regex findInString:string]; + 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); } static NSArray *getProperties(NSXMLNode *node, NSString *key) { 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