From d9fb89269fd30fa44d2b3728b9ae3c7b896a77d3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 3 Aug 2019 01:57:39 +0200 Subject: Properly remove html tag in search result on manganelo --- src/Manganelo.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/Manganelo.cpp') diff --git a/src/Manganelo.cpp b/src/Manganelo.cpp index 85a3802..de39c77 100644 --- a/src/Manganelo.cpp +++ b/src/Manganelo.cpp @@ -49,22 +49,24 @@ namespace QuickMedia { return result == 0 ? SearchResult::OK : SearchResult::ERR; } - static void remove_html_span(std::string &str) { + // Returns true if changed + static bool remove_html_span(std::string &str) { size_t open_tag_start = str.find("', open_tag_start + 5); if(open_tag_end == std::string::npos) - return; + return false; str.erase(open_tag_start, open_tag_end - open_tag_start + 1); size_t close_tag = str.find(""); if(close_tag == std::string::npos) - return; + return true; str.erase(close_tag, 7); + return true; } SuggestionResult Manganelo::update_search_suggestions(const std::string &text, std::vector> &result_items) { @@ -98,7 +100,7 @@ namespace QuickMedia { Json::Value name = child.get("name", ""); if(name.isString() && name.asCString()[0] != '\0') { std::string name_str = name.asString(); - remove_html_span(name_str); + while(remove_html_span(name_str)) {} auto item = std::make_unique(name_str); result_items.push_back(std::move(item)); } -- cgit v1.2.3