commit - ac07537e50ff7dce0e15a73d32c693c631c42844
commit + 05307fba348df783365077ec79f5af0279218daf
blob - 66a56b52d0b63ea301809a6d755c51735d4ce05c
blob + f5a9446bb7a163bd0e27552e7d77ae26c8e1aaab
--- tests/test_parse_url.cc
+++ tests/test_parse_url.cc
IS_TRUE(parse_url(cut_null("gemini:/"), zs_url_path) == url_too_short);
IS_TRUE(parse_url(cut_null("gemini1://"), zs_url_path) == url_non_gemini);
+ IS_TRUE(parse_url(cut_null("semini://"), zs_url_path) == url_non_gemini);
IS_TRUE(parse_url(cut_null("gemini://host/../secret.txt"), zs_url_path) == url_root_traverse);
IS_TRUE(parse_url(cut_null("gemini://host/dir/../../secret.txt"), zs_url_path) == url_root_traverse);
blob - 1ae1d8316e4b4cc89f93d82c35e39aa3dbbc9564
blob + 986a8632198ea80a95b2590c2c99dfd5ce756a35
--- vostok/parse_url.cc
+++ vostok/parse_url.cc
#include "error.h"
#include <list>
+#include <cctype>
namespace vostok
{
const auto gemini_scheme = cut_null("gemini://");
+inline bool is_gemini_scheme(span<const char> url)
+{
+ return std::equal(
+ gemini_scheme.begin(),
+ gemini_scheme.end(),
+ url.begin(),
+ [](char v1, char v2){return std::tolower(v1) == std::tolower(v2);}
+ );
+}
-
class path_normalization
{
public:
// check and skip scheme
if (url.size() < gemini_scheme.size())
return url_too_short;
- if (!std::equal(gemini_scheme.begin(), gemini_scheme.end(), url.begin()))
+ if (!is_gemini_scheme(url))
return url_non_gemini;
url = url.subspan(gemini_scheme.size());