Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

deal with malformed JSON files

  • Loading branch information...
commit 1f190b0f6fc18cb5810931f94f2ba92fcc0efe27 1 parent 66fad17
@pjrobertson authored
Showing with 12 additions and 7 deletions.
  1. +12 −7 OnePasswordSource.m
View
19 OnePasswordSource.m
@@ -156,19 +156,24 @@ - (NSArray *)objectsForEntry:(NSDictionary *)theEntry{
@autoreleasepool {
// For each .1pwd file in the filtered files
- for (NSString *dataPath in filteredFiles)
- {
-
+ for (NSString *dataPath in filteredFiles) {
NSData *JSONData = [NSData dataWithContentsOfFile:[dataFolder stringByAppendingPathComponent:dataPath]];
- NSDictionary *JSONDict = [JSONData yajl_JSON];
+ NSDictionary *JSONDict = nil;
+ @try {
+ JSONDict = [JSONData yajl_JSON];
+ }
+ @catch (NSException *exception) {
+ NSLog(@"Error parsing 1Password data for %@.\nException: %@",dataPath,exception);
+ continue;
+ }
// If there's something wrong with the JSON Dictionary
- if(!JSONDict) {
- NSLog(@"Error getting JSONDict");
+ if(JSONDict == nil) {
+ NSLog(@"Error getting JSONDict for %@",dataPath);
continue;
}
// Don't catalog trashed items
- if([JSONDict objectForKey:@"trashed"]) {
+ if([JSONDict objectForKey:@"trashed"] != nil && [[JSONDict objectForKey:@"trashed"] boolValue]) {
continue;
}
Please sign in to comment.
Something went wrong with that request. Please try again.