aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/util/UriUtil.cxx3
-rw-r--r--test/test_util.cxx4
2 files changed, 6 insertions, 1 deletions
diff --git a/src/util/UriUtil.cxx b/src/util/UriUtil.cxx
index 7997bd5c9..2609db2cf 100644
--- a/src/util/UriUtil.cxx
+++ b/src/util/UriUtil.cxx
@@ -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;
diff --git a/test/test_util.cxx b/test/test_util.cxx
index 2ff303540..a472391a3 100644
--- a/test/test_util.cxx
+++ b/test/test_util.cxx
@@ -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() {