Skip to content

Commit

Permalink
[Highly Complete / MIDI] Fix numeric tag reading
Browse files Browse the repository at this point in the history
The new Core Data interface is especially stringent with receiving
NSNumber for the numeric types rather than NSString as was mistakenly
allowed before. Fix that to prevent exceptions.

Signed-off-by: Christopher Snowhill <[email protected]>
  • Loading branch information
kode54 committed Jun 17, 2022
1 parent 3eca088 commit 67f6c93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Plugins/HighlyComplete/HighlyComplete/HCDecoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,12 @@ static int psf_info_meta(void *context, const char *name, const char *value) {
[taglc isEqualToString:@"albumartist"] ||
[taglc isEqualToString:@"artist"] ||
[taglc isEqualToString:@"album"] ||
[taglc isEqualToString:@"year"] ||
[taglc isEqualToString:@"genre"] ||
[taglc isEqualToString:@"genre"]) {
[state->info setObject:svalue forKey:taglc];
} else if([taglc isEqualToString:@"year"] ||
[taglc isEqualToString:@"track"] ||
[taglc isEqualToString:@"disc"]) {
[state->info setObject:svalue forKey:taglc];
[state->info setObject:[NSNumber numberWithInt:[svalue intValue]] forKey:taglc];
}

return 0;
Expand Down
7 changes: 5 additions & 2 deletions Plugins/MIDI/MIDI/MIDIMetadataReader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ + (NSDictionary *)metadataForURL:(NSURL *)url {
midi_meta_data_item item;
bool remap_display_name = !metadata.get_item("title", item);

NSArray *allowedKeys = @[@"title", @"artist", @"albumartist", @"album", @"year", @"genre"];
NSArray *allowedKeys = @[@"title", @"artist", @"albumartist", @"album", @"genre"];

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:10];

Expand All @@ -72,8 +72,11 @@ + (NSDictionary *)metadataForURL:(NSURL *)url {
if(![name isEqualToString:@"type"]) {
if(remap_display_name && [name isEqualToString:@"display_name"])
name = @"title";
if([allowedKeys containsObject:name])
if([allowedKeys containsObject:name]) {
[dict setObject:guess_encoding_of_string(item.m_value.c_str()) forKey:name];
} else if([name isEqualToString:@"year"]) {
[dict setObject:[NSNumber numberWithInt:[guess_encoding_of_string(item.m_value.c_str()) intValue]] forKey:name];
}
}
}

Expand Down

0 comments on commit 67f6c93

Please sign in to comment.