libarchive: sanitize non-UTF8 archive entries

Some client API users simply don't like such filenames. For their sake,
don't return them, but return a dummy filename instead. (Returning a
latin1-ized version would work too, but is slightly more work.)

Also remove the "\n" from the replacement dummy filename. This was
accidental.
This commit is contained in:
wm4 2016-07-18 12:52:59 +02:00
parent fb8deb69a6
commit 510c6a1be4
1 changed files with 2 additions and 2 deletions

View File

@ -290,8 +290,8 @@ bool mp_archive_next_entry(struct mp_archive *mpa)
// Some archives may have no filenames, or libarchive won't return some.
const char *fn = archive_entry_pathname(entry);
char buf[64];
if (!fn) {
snprintf(buf, sizeof(buf), "mpv_unknown#%d\n", mpa->entry_num);
if (!fn || bstr_validate_utf8(bstr0(fn)) < 0) {
snprintf(buf, sizeof(buf), "mpv_unknown#%d", mpa->entry_num);
fn = buf;
}
mpa->entry = entry;