forked from old/legacy-imlib2
gz, bz2 loaders: Fix recent breakage when file name has more than two dots
This commit is contained in:
parent
1a0c29c873
commit
8bd07dbcea
|
@ -51,14 +51,20 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
ImlibLoader *loader;
|
||||
FILE *fp;
|
||||
int dest, res;
|
||||
char *file, *p, *q, tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX";
|
||||
char *real_ext;
|
||||
const char *s, *p, *q;
|
||||
char tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX";
|
||||
char *file, *real_ext;
|
||||
|
||||
/* make sure this file ends in ".bz2" and that there's another ext
|
||||
* (e.g. "foo.png.bz2") */
|
||||
p = strrchr(im->real_file, '.');
|
||||
q = strchr(im->real_file, '.');
|
||||
if (!p || p == im->real_file || strcasecmp(p + 1, "bz2") || p == q)
|
||||
for (s = im->real_file, p = q = NULL; *s; s++)
|
||||
{
|
||||
if (*s != '.')
|
||||
continue;
|
||||
q = p;
|
||||
p = s;
|
||||
}
|
||||
if (!q || q == im->real_file || strcasecmp(p + 1, "bz2"))
|
||||
return 0;
|
||||
|
||||
if (!(real_ext = strndup(q + 1, p - q - 1)))
|
||||
|
|
|
@ -44,14 +44,20 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
ImlibLoader *loader;
|
||||
FILE *fp;
|
||||
int dest, res;
|
||||
char *file, *p, *q, tmp[] = "/tmp/imlib2_loader_zlib-XXXXXX";
|
||||
char *real_ext;
|
||||
const char *s, *p, *q;
|
||||
char tmp[] = "/tmp/imlib2_loader_zlib-XXXXXX";
|
||||
char *file, *real_ext;
|
||||
|
||||
/* make sure this file ends in ".gz" and that there's another ext
|
||||
* (e.g. "foo.png.gz") */
|
||||
p = strrchr(im->real_file, '.');
|
||||
q = strchr(im->real_file, '.');
|
||||
if (!p || p == im->real_file || strcasecmp(p + 1, "gz") || p == q)
|
||||
for (s = im->real_file, p = q = NULL; *s; s++)
|
||||
{
|
||||
if (*s != '.')
|
||||
continue;
|
||||
q = p;
|
||||
p = s;
|
||||
}
|
||||
if (!q || q == im->real_file || strcasecmp(p + 1, "gz"))
|
||||
return 0;
|
||||
|
||||
if (!(real_ext = strndup(q + 1, p - q - 1)))
|
||||
|
|
Loading…
Reference in New Issue