Revision: 26893
          http://sourceforge.net/p/bibdesk/svn/26893
Author:   hofman
Date:     2021-09-15 16:48:26 +0000 (Wed, 15 Sep 2021)
Log Message:
-----------
Allow getting linked files and urls when special fields are lowercased

Modified Paths:
--------------
    trunk/bibdesk/BDSKBibTeXParser.m
    trunk/bibdesk/BibItem.m

Modified: trunk/bibdesk/BDSKBibTeXParser.m
===================================================================
--- trunk/bibdesk/BDSKBibTeXParser.m    2021-09-15 16:28:49 UTC (rev 26892)
+++ trunk/bibdesk/BDSKBibTeXParser.m    2021-09-15 16:48:26 UTC (rev 26893)
@@ -1063,7 +1063,7 @@
         
         // Special case handling of abstract & annote is to avoid losing 
newlines in preexisting files.
         // In addition, we need to preserve newlines in file fields for base64 
decoding, instead of replacing with a space.
-        if([fieldName isNoteField] || [fieldName hasPrefix:@"Bdsk-File-"]){
+        if([fieldName isNoteField] || [fieldName 
hasCaseInsensitivePrefix:@"Bdsk-File-"]){
             
             // this is guaranteed to point to a meaningful error if 
copyStringFromNoteField fails
             NSString *errorString = nil;

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2021-09-15 16:28:49 UTC (rev 26892)
+++ trunk/bibdesk/BibItem.m     2021-09-15 16:48:26 UTC (rev 26893)
@@ -4062,6 +4062,19 @@
     }
 }
 
+static BOOL getValueForKey(NSDictionary *dict, NSString **key, NSString 
**value) {
+    *value = [dict objectForKey:*key];
+    if (*value)
+        return YES;
+    NSString *lowerKey = [*key lowercaseString];
+    *value = [dict objectForKey:lowerKey];
+    if (*value) {
+        *key = lowerKey;
+        return YES;
+    }
+    return NO;
+}
+
 - (void)createFilesArray
 {        
     NSUInteger i = 1;
@@ -4071,7 +4084,7 @@
     NSMutableArray *unresolvedFiles = [NSMutableArray new];
     NSMutableArray *unresolvedURLs = [NSMutableArray new];
     
-    while ((value = [pubFields objectForKey:key]) != nil) {
+    while (getValueForKey(pubFields, &key, &value)) {
         BDSKLinkedFile *aFile = [[BDSKLinkedFile alloc] 
initWithBase64String:value delegate:self];
         if (aFile) {
             [files addObject:aFile];
@@ -4091,7 +4104,7 @@
     i = 1;
     key = @"Bdsk-Url-1";
     
-    while ((value = [pubFields objectForKey:key]) != nil) {
+    while (getValueForKey(pubFields, &key, &value)) {
         BDSKLinkedFile *aURL = [[BDSKLinkedFile alloc] 
initWithURLString:value];
         if (aURL) {
             [files addObject:aURL];

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

Reply via email to