diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2023-01-14 18:14:03 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2023-01-14 18:14:03 +0100 |
commit | d37076a33296877fee3154db689f2990785aed94 (patch) | |
tree | 32a5eac40012a92c05eea81d401147b00fe18bef /src/util.cc | |
parent | 8a7f76e7a1b404dc7f703d09d724defaee9e4238 (diff) |
Escape all user-input strings when writing configuration.cc
Diffstat (limited to 'src/util.cc')
-rw-r--r-- | src/util.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc index 601fd54..08a135f 100644 --- a/src/util.cc +++ b/src/util.cc @@ -188,3 +188,20 @@ ctor::target_type target_type_from_extension(const std::filesystem::path& file) return ctor::target_type::unknown; } + +std::string esc(const std::string& in) +{ + std::string out; + for(auto c : in) + { + switch(c) + { + case '\\': out += "\\\\"; break; + case '"': out += "\\\""; break; + default: + out += c; + break; + } + } + return out; +} |