diff --git a/src/backend/helpers.cpp b/src/backend/helpers.cpp index 8de6943f..61db42fa 100644 --- a/src/backend/helpers.cpp +++ b/src/backend/helpers.cpp @@ -116,9 +116,6 @@ namespace loot { regex(regex7, regex::ECMAScript | regex::icase) }; - // A regular expression for finding Bash Tags in plugin descriptions. - const regex bash_tag_check("\\{\\{BASH:(?:[ ]*([-A-Za-z.]+)[ ]*,)+[ ]*\\}\\}", regex::ECMAScript | regex::icase); - ////////////////////////////////////////////////////////////////////////// // Helper functions ////////////////////////////////////////////////////////////////////////// diff --git a/src/backend/helpers.h b/src/backend/helpers.h index 17cb3bcb..5ed1a9be 100644 --- a/src/backend/helpers.h +++ b/src/backend/helpers.h @@ -38,9 +38,6 @@ namespace loot { /// an iteration for each of them. extern const std::regex version_checks[7]; - // A regular expression for finding Bash Tags in plugin descriptions. - extern const std::regex bash_tag_check; - ////////////////////////////////////////////////////////////////////////// // Helper functions ////////////////////////////////////////////////////////////////////////// diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index 86fc5195..4a69789d 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -397,15 +397,22 @@ namespace loot { } } BOOST_LOG_TRIVIAL(trace) << name << ": " << "Attempting to extract Bash Tags from the description."; - smatch results; - if (regex_search(text, results, bash_tag_check)) { - // Regex requires there to be at least one sub-expression match, - // so skip the first (which is the full expression. - for (size_t i = 1; i < results.size(); ++i) { - // Tags in the description must be addition tags, because there's - // nowhere else to remove them from. - auto tag = tags.insert(Tag(string(results[i].first, results[i].second))); - BOOST_LOG_TRIVIAL(trace) << name << ": " << "Extracted Bash Tag: " << tag.first->Name(); + size_t pos1 = text.find("{{BASH:"); + if (pos1 != string::npos && pos1 + 7 != text.length()) { + pos1 += 7; + + size_t pos2 = text.find("}}", pos1); + if (pos2 != string::npos) { + text = text.substr(pos1, pos2 - pos1); + + vector bashTags; + boost::split(bashTags, text, boost::is_any_of(",")); + + for (auto &tag : bashTags) { + boost::trim(tag); + BOOST_LOG_TRIVIAL(trace) << name << ": " << "Extracted Bash Tag: " << tag; + tags.insert(Tag(tag)); + } } } }