[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>
xcode15
Christopher Snowhill 2022-07-03 14:30:29 -07:00
parent 6a46389310
commit 969bf4f502
1 changed files with 7 additions and 2 deletions

View File

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