util/UriUtil: uri_get_suffix() fails if name begins with dot
A file called ".jpg" is not a JPEG file with an empty name; it is merely a hidden file.
This commit is contained in:
parent
d7f80eab68
commit
afc70c120e
|
@ -32,7 +32,8 @@ const char *
|
|||
uri_get_suffix(const char *uri)
|
||||
{
|
||||
const char *suffix = strrchr(uri, '.');
|
||||
if (suffix == nullptr)
|
||||
if (suffix == nullptr || suffix == uri ||
|
||||
suffix[-1] == '/' || suffix[-1] == '\\')
|
||||
return nullptr;
|
||||
|
||||
++suffix;
|
||||
|
|
|
@ -29,6 +29,10 @@ public:
|
|||
"jpg"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo.png/bar.jpg"),
|
||||
"jpg"));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
|
||||
uri_get_suffix(".jpg"));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
|
||||
uri_get_suffix("/foo/.jpg"));
|
||||
}
|
||||
|
||||
void TestRemoveAuth() {
|
||||
|
|
Loading…
Reference in New Issue