From e9db3fab3a84a4ef8f360de15c60f052ef3dd56e Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Thu, 1 Dec 2016 14:30:46 +0100 Subject: [PATCH] fix: Only escape delimiter within action blocks Ref #197 --- src/components/builder.cpp | 8 -------- src/components/parser.cpp | 13 ++++++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/builder.cpp b/src/components/builder.cpp index 4050d4c7..fa70ca61 100644 --- a/src/components/builder.cpp +++ b/src/components/builder.cpp @@ -145,10 +145,6 @@ void builder::node(string str, bool add_space) { overline_close(); s.erase(0, 5); - } else if ((n = s.find("%{A}")) == 0) { - cmd_close(); - s.erase(0, 4); - } else if ((n = s.find("%{")) == 0 && (m = s.find('}')) != string::npos) { append(s.substr(n, m + 1)); s.erase(n, m + 1); @@ -506,10 +502,6 @@ void builder::cmd(mousebtn index, string action, bool condition) { } action = string_util::replace_all(action, ":", "\\:"); - action = string_util::replace_all(action, "$", "\\$"); - action = string_util::replace_all(action, "}", "\\}"); - action = string_util::replace_all(action, "{", "\\{"); - action = string_util::replace_all(action, "%", "\x0025"); tag_open(syntaxtag::A, to_string(button) + ":" + action + ":"); } diff --git a/src/components/parser.cpp b/src/components/parser.cpp index 45f9ba93..a38a75bf 100644 --- a/src/components/parser.cpp +++ b/src/components/parser.cpp @@ -266,11 +266,18 @@ mousebtn parser::parse_action_btn(string data) { * Process action command string */ string parser::parse_action_cmd(const string& data) { - size_t start, end; - if ((start = data.find(':')) == string::npos) { + size_t start{0}; + while ((start = data.find(':', start)) != string::npos && data[start - 1] == '\\') { + start++; + } + if (start == string::npos) { return ""; } - if ((end = data.find(':', start + 1)) == string::npos) { + size_t end{start + 1}; + while ((end = data.find(':', end)) != string::npos && data[end - 1] == '\\') { + end++; + } + if (end == string::npos) { return ""; } return string_util::trim(data.substr(start, end), ':');