diff --git a/src/shrpx_ssl.cc b/src/shrpx_ssl.cc index b3cf2537..0a7ca6ac 100644 --- a/src/shrpx_ssl.cc +++ b/src/shrpx_ssl.cc @@ -808,8 +808,8 @@ bool tls_hostname_match(const char *pattern, const char *hostname) { return false; } return util::istarts_with(hostname, hnLeftLabelEnd, pattern, ptWildcard) && - util::iendsWith(hostname, hnLeftLabelEnd, ptWildcard + 1, - ptLeftLabelEnd); + util::iends_with(hostname, hnLeftLabelEnd, ptWildcard + 1, + ptLeftLabelEnd); } } // namespace diff --git a/src/util.cc b/src/util.cc index 5d884b3c..2962e152 100644 --- a/src/util.cc +++ b/src/util.cc @@ -521,8 +521,8 @@ void show_candidates(const char *unkopt, option *options) { } // Use cost 0 for suffix match, but match at least 3 characters if (unkoptlen >= 3 && - iendsWith(options[i].name, options[i].name + optnamelen, unkopt, - unkopt + unkoptlen)) { + iends_with(options[i].name, options[i].name + optnamelen, unkopt, + unkopt + unkoptlen)) { cands.emplace_back(0, options[i].name); continue; } @@ -754,7 +754,7 @@ bool check_path(const std::string &path) { path.find('\\') == std::string::npos && path.find("/../") == std::string::npos && path.find("/./") == std::string::npos && - !util::endsWith(path, "/..") && !util::endsWith(path, "/."); + !util::ends_with(path, "/..") && !util::ends_with(path, "/."); } int64_t to_time64(const timeval &tv) { diff --git a/src/util.h b/src/util.h index 7fcc7817..a4468bcb 100644 --- a/src/util.h +++ b/src/util.h @@ -212,29 +212,29 @@ bool istarts_with(InputIt a, size_t an, const char *b) { bool istarts_with(const char *a, const char *b); template -bool endsWith(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2) { +bool ends_with(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { if (last1 - first1 < last2 - first2) { return false; } return std::equal(first2, last2, last1 - (last2 - first2)); } -inline bool endsWith(const std::string &a, const std::string &b) { - return endsWith(std::begin(a), std::end(a), std::begin(b), std::end(b)); +inline bool ends_with(const std::string &a, const std::string &b) { + return ends_with(std::begin(a), std::end(a), std::begin(b), std::end(b)); } template -bool iendsWith(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2) { +bool iends_with(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { if (last1 - first1 < last2 - first2) { return false; } return std::equal(first2, last2, last1 - (last2 - first2), CaseCmp()); } -inline bool iendsWith(const std::string &a, const std::string &b) { - return iendsWith(std::begin(a), std::end(a), std::begin(b), std::end(b)); +inline bool iends_with(const std::string &a, const std::string &b) { + return iends_with(std::begin(a), std::end(a), std::begin(b), std::end(b)); } int strcompare(const char *a, const uint8_t *b, size_t n); diff --git a/src/util_test.cc b/src/util_test.cc index 19cdbf90..adc079f6 100644 --- a/src/util_test.cc +++ b/src/util_test.cc @@ -356,15 +356,15 @@ void test_util_starts_with(void) { } void test_util_ends_with(void) { - CU_ASSERT(util::endsWith("foo", "foo")); - CU_ASSERT(util::endsWith("foo", "")); - CU_ASSERT(util::endsWith("ofoo", "foo")); - CU_ASSERT(!util::endsWith("ofoo", "fo")); + CU_ASSERT(util::ends_with("foo", "foo")); + CU_ASSERT(util::ends_with("foo", "")); + CU_ASSERT(util::ends_with("ofoo", "foo")); + CU_ASSERT(!util::ends_with("ofoo", "fo")); - CU_ASSERT(util::iendsWith("fOo", "Foo")); - CU_ASSERT(util::iendsWith("foo", "")); - CU_ASSERT(util::iendsWith("oFoo", "fOO")); - CU_ASSERT(!util::iendsWith("ofoo", "fo")); + CU_ASSERT(util::iends_with("fOo", "Foo")); + CU_ASSERT(util::iends_with("foo", "")); + CU_ASSERT(util::iends_with("oFoo", "fOO")); + CU_ASSERT(!util::iends_with("ofoo", "fo")); } void test_util_parse_http_date(void) {