[M3U Playlist] Reformulate safety checks

Apparently someone managed to crash this with their playlists. No idea
how. Added more safety checks.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
lastfm
Christopher Snowhill 2022-07-03 14:30:29 -07:00
parent 7f1c337ee8
commit b3e0da6fe9
1 changed files with 7 additions and 2 deletions

View File

@ -122,14 +122,19 @@
for(NSString *entry in [contents componentsSeparatedByString:@"\n"]) {
NSString *_entry = [entry stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if(_entry == nil || [_entry length] < 1) continue;
if([_entry hasPrefix:@"#EXT-X-MEDIA-SEQUENCE"]) // Let FFmpeg handle HLS
return @[];
if([_entry hasPrefix:@"#"] || [_entry isEqualToString:@""]) // Ignore extra info
if([_entry hasPrefix:@"#"]) // Ignore extra info
continue;
// Need to add basePath, and convert to URL
[entries addObject:[self urlForPath:_entry relativeTo:[url path]]];
NSURL *fileUrl = [self urlForPath:_entry relativeTo:[url path]];
if(fileUrl)
[entries addObject:fileUrl];
}
return entries;