gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit f0202a0f3c2de18642da5027901f4dc80e149fd7
parent b88e95f965fece5244c26c3527e6a1aecc743bc0
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Thu, 14 Nov 2024 19:28:27 +0100

fix missing escape of variable values in ttl files

Diffstat:
Msource/synthLib/lv2PresetExport.cpp | 18+++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/source/synthLib/lv2PresetExport.cpp b/source/synthLib/lv2PresetExport.cpp @@ -70,6 +70,22 @@ namespace synthLib return _name; } + std::string escapeValue(const std::string& _value) + { + std::string escaped; + escaped.reserve(_value.size()); + for (const auto c : _value) + { + switch (c) + { + case '"': escaped.append("\\\""); break; + case '\\': escaped.append("\\\\"); break; + default: escaped.push_back(c); break; + } + } + return escaped; + } + std::string replaceVariables(std::string _string, const std::map<std::string, std::string>& _variables) { for (const auto& [key, value] : _variables) @@ -80,7 +96,7 @@ namespace synthLib if(pos == std::string::npos) break; _string.erase(pos, key.size()); - _string.insert(pos, value); + _string.insert(pos, escapeValue(value)); } } return _string;