diff --git a/matrix/app.cc b/matrix/app.cc index d8384247d..4f58efa50 100644 --- a/matrix/app.cc +++ b/matrix/app.cc @@ -200,12 +200,14 @@ ircd::m::app::app(const m::event::idx &event_idx) arg.at(0) }; - string_view part[2]; - part[0] = path; - part[1] = file; + const string_view part[2] + { + path, file + }; + const auto ret { - fs::path_string(part) + fs::path_string(path, part) }; if(!bin.count(ret)) diff --git a/modules/m_command.cc b/modules/m_command.cc index 7deebb913..ff9e76fb9 100644 --- a/modules/m_command.cc +++ b/modules/m_command.cc @@ -878,24 +878,16 @@ command__edit(const mutable_buffer &buf_, "Configure the 'ircd.m.cmd.edit.path' to use this feature.", }; + const string_view parts[2] + { + edit_path, param["path"] + }; + const string_view path { - fs::canonical(buf_, edit_path, param["path"]) + fs::path(buf_, edit_path, parts) }; - const string_view root - { - fs::canonical(fs::path_scratch, edit_path) - }; - - if(!startswith(path, root)) - throw m::NOT_FOUND - { - "File `%s' was not found under `%s'", - path, - root, - }; - const fs::fd fd { path @@ -1015,24 +1007,16 @@ try if(!body) return; + const string_view path_parts[2] + { + edit_path, args + }; + const std::string path { - fs::canonical(fs::path_scratch, edit_path, args) + fs::path(fs::path_scratch, edit_path, path_parts) }; - const string_view root - { - fs::canonical(fs::path_scratch, edit_path) - }; - - if(!startswith(path, root)) - throw m::ACCESS_DENIED - { - "File `%s' is not under accessible directory `%s'", - path, - root, - }; - fs::write_opts wopts; const const_buffer written {