mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Fix loading of archived content with file names containing '#' characters
This commit is contained in:
parent
d8a5505204
commit
b5df2b883a
@ -90,38 +90,44 @@ const char *path_get_archive_delim(const char *path)
|
|||||||
if (!last_slash)
|
if (!last_slash)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Find delimiter position */
|
/* Find delimiter position
|
||||||
delim = strrchr(last_slash, '#');
|
* > Since filenames may contain '#' characters,
|
||||||
|
* must loop until we find the first '#' that
|
||||||
|
* is directly *after* a compression extension */
|
||||||
|
delim = strchr(last_slash, '#');
|
||||||
|
|
||||||
if (!delim)
|
while (delim)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Check whether this is a known archive type
|
|
||||||
* > Note: The code duplication here is
|
|
||||||
* deliberate, to maximise performance */
|
|
||||||
if (delim - last_slash > 4)
|
|
||||||
{
|
{
|
||||||
strlcpy(buf, delim - 4, sizeof(buf));
|
/* Check whether this is a known archive type
|
||||||
buf[4] = '\0';
|
* > Note: The code duplication here is
|
||||||
|
* deliberate, to maximise performance */
|
||||||
|
if (delim - last_slash > 4)
|
||||||
|
{
|
||||||
|
strlcpy(buf, delim - 4, sizeof(buf));
|
||||||
|
buf[4] = '\0';
|
||||||
|
|
||||||
string_to_lower(buf);
|
string_to_lower(buf);
|
||||||
|
|
||||||
/* Check if this is a '.zip', '.apk' or '.7z' file */
|
/* Check if this is a '.zip', '.apk' or '.7z' file */
|
||||||
if (string_is_equal(buf, ".zip") ||
|
if (string_is_equal(buf, ".zip") ||
|
||||||
string_is_equal(buf, ".apk") ||
|
string_is_equal(buf, ".apk") ||
|
||||||
string_is_equal(buf + 1, ".7z"))
|
string_is_equal(buf + 1, ".7z"))
|
||||||
return delim;
|
return delim;
|
||||||
}
|
}
|
||||||
else if (delim - last_slash > 3)
|
else if (delim - last_slash > 3)
|
||||||
{
|
{
|
||||||
strlcpy(buf, delim - 3, sizeof(buf));
|
strlcpy(buf, delim - 3, sizeof(buf));
|
||||||
buf[3] = '\0';
|
buf[3] = '\0';
|
||||||
|
|
||||||
string_to_lower(buf);
|
string_to_lower(buf);
|
||||||
|
|
||||||
/* Check if this is a '.7z' file */
|
/* Check if this is a '.7z' file */
|
||||||
if (string_is_equal(buf, ".7z"))
|
if (string_is_equal(buf, ".7z"))
|
||||||
return delim;
|
return delim;
|
||||||
|
}
|
||||||
|
|
||||||
|
delim++;
|
||||||
|
delim = strchr(delim, '#');
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user