Revision: 21901
          http://sourceforge.net/p/bibdesk/svn/21901
Author:   hofman
Date:     2018-02-12 15:51:22 +0000 (Mon, 12 Feb 2018)
Log Message:
-----------
Let NSString get download the bibtex string

Modified Paths:
--------------
    trunk/bibdesk/BDSKLinkedBibTeXParser.m

Modified: trunk/bibdesk/BDSKLinkedBibTeXParser.m
===================================================================
--- trunk/bibdesk/BDSKLinkedBibTeXParser.m      2018-02-12 07:30:42 UTC (rev 
21900)
+++ trunk/bibdesk/BDSKLinkedBibTeXParser.m      2018-02-12 15:51:22 UTC (rev 
21901)
@@ -104,42 +104,19 @@
         }
         
         NSURL *btURL = [NSURL URLWithString:btURLString];
-    
-        NSURLRequest *request = [NSURLRequest requestWithURL:btURL 
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60.0];
         NSURLResponse *response;
-    
-        NSData *theData = [NSURLConnection sendSynchronousRequest:request 
returningResponse:&response error:&error];
-        NSString *bibTeXString = nil;
-    
-        if (nil != theData) {
-            
-            NSString *encodingName = [response textEncodingName];
-            NSStringEncoding encoding = kCFStringEncodingInvalidId;
-            
-            if (nil != encodingName)
-                encoding = 
CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encodingName));
-            
-            if (encoding != kCFStringEncodingInvalidId)
-                bibTeXString = [[NSString alloc] initWithData:theData 
encoding:encoding];
-            else
-                bibTeXString = [[NSString alloc] initWithData:theData 
encoding:NSUTF8StringEncoding];
-            
-            if (nil == bibTeXString)
-                bibTeXString = [[NSString alloc] initWithData:theData 
encoding:NSISOLatin1StringEncoding];
-            
-            [bibTeXString autorelease];
-        }
-    
+        
+        NSStringEncoding encoding = kCFStringEncodingInvalidId;
+        NSString *bibTeXString = [NSString stringWithContentsOfURL:btURL 
usedEncoding:&encoding error:&error];
         NSArray *bibtexItems = nil;
-    
+        
         if (nil != bibTeXString)
             bibtexItems = [BDSKBibTeXParser itemsFromString:bibTeXString 
owner:nil error:&error];
-    
+        
         if ([bibtexItems count] && [error 
isLocalErrorWithCode:kBDSKBibTeXParserFailed] == NO) {
             BibItem *bibtexItem = [bibtexItems objectAtIndex:0];
             [self postProcessItem:bibtexItem];
             [items addObject:bibtexItem];
-            
         } else {
             // display a fake item in the table so the user knows one of the 
items failed to parse, but still gets the rest of the data
             NSString *errMsg = NSLocalizedString(@"Unable to parse as BibTeX", 
@"Web parser error");
@@ -149,7 +126,7 @@
             [errorItem release];
         }
      }
-
+    
     return items;
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to