diff --git a/include/crow/http_response.h b/include/crow/http_response.h index 20d5157ce..bfae40517 100644 --- a/include/crow/http_response.h +++ b/include/crow/http_response.h @@ -214,10 +214,16 @@ namespace crow int statResult; }; - ///Return a static file as the response body + /// Return a static file as the response body void set_static_file_info(std::string path) { utility::sanitize_filename(path); + set_static_file_info_unsafe(path); + } + + /// Return a static file as the response body without sanitizing the path (use set_static_file_info instead) + void set_static_file_info_unsafe(std::string path) + { file_info.path = path; file_info.statResult = stat(file_info.path.c_str(), &file_info.statbuf); #ifdef CROW_ENABLE_COMPRESSION diff --git a/include/crow/mustache.h b/include/crow/mustache.h index 85ae6f668..902d59970 100644 --- a/include/crow/mustache.h +++ b/include/crow/mustache.h @@ -637,11 +637,21 @@ namespace crow return detail::get_loader_ref()(filename_sanitized); } + inline std::string load_text_unsafe(const std::string& filename) + { + return detail::get_loader_ref()(filename); + } + inline template_t load(const std::string& filename) { std::string filename_sanitized(filename); utility::sanitize_filename(filename_sanitized); return compile(detail::get_loader_ref()(filename_sanitized)); } + + inline template_t load_unsafe(const std::string& filename) + { + return compile(detail::get_loader_ref()(filename)); + } } // namespace mustache } // namespace crow