From 18f4a58237b853a67a7894587e1dfc2a4ca68fa3 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 13:45:16 +0400 Subject: [PATCH 01/11] Conception of kiwix::Suggestions --- src/server/internalServer.cpp | 2 +- src/tools/otherTools.cpp | 5 +++++ src/tools/otherTools.h | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index ceb5dc41b..3eca3f3b9 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -700,7 +700,7 @@ std::unique_ptr InternalServer::handle_suggest(const RequestContext& r printf("Searching suggestions for: \"%s\"\n", queryString.c_str()); } - MustacheData results{MustacheData::type::list}; + Suggestions results; bool first = true; diff --git a/src/tools/otherTools.cpp b/src/tools/otherTools.cpp index 13b2172e8..99458349d 100644 --- a/src/tools/otherTools.cpp +++ b/src/tools/otherTools.cpp @@ -326,3 +326,8 @@ std::string kiwix::render_template(const std::string& template_str, kainjow::mus tmpl.render(data, [&ss](const std::string& str) { ss << str; }); return ss.str(); } + +kiwix::Suggestions::Suggestions() + : kainjow::mustache::data(kainjow::mustache::data::type::list) +{ +} diff --git a/src/tools/otherTools.h b/src/tools/otherTools.h index e00a35858..f16f2ab6a 100644 --- a/src/tools/otherTools.h +++ b/src/tools/otherTools.h @@ -67,6 +67,12 @@ namespace kiwix return defaultValue; } + + class Suggestions : public kainjow::mustache::data + { + public: + Suggestions(); + }; } #endif From f36f1661d503b7c5539bc5c40f56e0b33650b88a Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 13:53:18 +0400 Subject: [PATCH 02/11] Got rid of result count tracker variable --- src/server/internalServer.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 3eca3f3b9..163e633f2 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -702,8 +702,6 @@ std::unique_ptr InternalServer::handle_suggest(const RequestContext& r Suggestions results; - bool first = true; - /* Get the suggestions */ auto searcher = suggestionSearcherCache.getOrPut(bookId, [=](){ return make_shared(*archive); } @@ -723,8 +721,7 @@ std::unique_ptr InternalServer::handle_suggest(const RequestContext& r result.set("value", suggestion.getTitle()); result.set("kind", "path"); result.set("path", suggestion.getPath()); - result.set("first", first); - first = false; + result.set("first", results.is_empty_list()); results.push_back(result); } @@ -736,7 +733,7 @@ std::unique_ptr InternalServer::handle_suggest(const RequestContext& r result.set("label", makeFulltextSearchSuggestion(lang, queryString)); result.set("value", queryString + " "); result.set("kind", "pattern"); - result.set("first", first); + result.set("first", results.is_empty_list()); results.push_back(result); } From 51bd881211506b507597aca34a10c33844f8e7af Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 13:58:22 +0400 Subject: [PATCH 03/11] kiwix::Suggestions::add() --- src/server/internalServer.cpp | 13 +------------ src/tools/otherTools.cpp | 17 +++++++++++++++++ src/tools/otherTools.h | 6 ++++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 163e633f2..13b82a2b1 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -711,18 +711,7 @@ std::unique_ptr InternalServer::handle_suggest(const RequestContext& r auto srs = search.getResults(start, count); for(auto& suggestion: srs) { - MustacheData result; - result.set("label", suggestion.getTitle()); - - if (suggestion.hasSnippet()) { - result.set("label", suggestion.getSnippet()); - } - - result.set("value", suggestion.getTitle()); - result.set("kind", "path"); - result.set("path", suggestion.getPath()); - result.set("first", results.is_empty_list()); - results.push_back(result); + results.add(suggestion); } diff --git a/src/tools/otherTools.cpp b/src/tools/otherTools.cpp index 99458349d..82c80c9c3 100644 --- a/src/tools/otherTools.cpp +++ b/src/tools/otherTools.cpp @@ -38,6 +38,7 @@ #include #include +#include static std::map codeisomapping { @@ -331,3 +332,19 @@ kiwix::Suggestions::Suggestions() : kainjow::mustache::data(kainjow::mustache::data::type::list) { } + +void kiwix::Suggestions::add(const zim::SuggestionItem& suggestion) +{ + kainjow::mustache::data result; + result.set("label", suggestion.getTitle()); + + if (suggestion.hasSnippet()) { + result.set("label", suggestion.getSnippet()); + } + + result.set("value", suggestion.getTitle()); + result.set("kind", "path"); + result.set("path", suggestion.getPath()); + result.set("first", this->is_empty_list()); + this->push_back(result); +} diff --git a/src/tools/otherTools.h b/src/tools/otherTools.h index f16f2ab6a..80d9582a8 100644 --- a/src/tools/otherTools.h +++ b/src/tools/otherTools.h @@ -33,6 +33,10 @@ namespace pugi { class xml_node; } +namespace zim { + class SuggestionItem; +} + namespace kiwix { std::string nodeToString(const pugi::xml_node& node); @@ -72,6 +76,8 @@ namespace kiwix { public: Suggestions(); + + void add(const zim::SuggestionItem& suggestion); }; } From 7a9780eb90f8d329c3ffc0831d24114010b7f731 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 14:11:37 +0400 Subject: [PATCH 04/11] kiwix::Suggestions::addFTSearchSuggestion() --- src/server/internalServer.cpp | 17 +---------------- src/tools/otherTools.cpp | 27 +++++++++++++++++++++++++++ src/tools/otherTools.h | 3 +++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 13b82a2b1..38ec37903 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -138,15 +138,6 @@ std::string renderUrl(const std::string& root, const std::string& urlTemplate) return url; } -std::string makeFulltextSearchSuggestion(const std::string& lang, const std::string& queryString) -{ - return i18n::expandParameterizedString(lang, "suggest-full-text-search", - { - {"SEARCH_TERMS", queryString} - } - ); -} - ParameterizedMessage noSuchBookErrorMsg(const std::string& bookName) { return ParameterizedMessage("no-such-book", { {"BOOK_NAME", bookName} }); @@ -717,13 +708,7 @@ std::unique_ptr InternalServer::handle_suggest(const RequestContext& r /* Propose the fulltext search if possible */ if (archive->hasFulltextIndex()) { - MustacheData result; - const auto lang = request.get_user_language(); - result.set("label", makeFulltextSearchSuggestion(lang, queryString)); - result.set("value", queryString + " "); - result.set("kind", "pattern"); - result.set("first", results.is_empty_list()); - results.push_back(result); + results.addFTSearchSuggestion(request.get_user_language(), queryString); } auto data = get_default_data(); diff --git a/src/tools/otherTools.cpp b/src/tools/otherTools.cpp index 82c80c9c3..282c604f1 100644 --- a/src/tools/otherTools.cpp +++ b/src/tools/otherTools.cpp @@ -32,6 +32,7 @@ #endif #include "tools/stringTools.h" +#include "server/i18n.h" #include #include @@ -328,6 +329,21 @@ std::string kiwix::render_template(const std::string& template_str, kainjow::mus return ss.str(); } +namespace +{ + +std::string makeFulltextSearchSuggestion(const std::string& lang, + const std::string& queryString) +{ + return kiwix::i18n::expandParameterizedString(lang, "suggest-full-text-search", + { + {"SEARCH_TERMS", queryString} + } + ); +} + +} // unnamed namespace + kiwix::Suggestions::Suggestions() : kainjow::mustache::data(kainjow::mustache::data::type::list) { @@ -348,3 +364,14 @@ void kiwix::Suggestions::add(const zim::SuggestionItem& suggestion) result.set("first", this->is_empty_list()); this->push_back(result); } + +void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang, + const std::string& queryString) +{ + kainjow::mustache::data result; + result.set("label", makeFulltextSearchSuggestion(uiLang, queryString)); + result.set("value", queryString + " "); + result.set("kind", "pattern"); + result.set("first", this->is_empty_list()); + this->push_back(result); +} diff --git a/src/tools/otherTools.h b/src/tools/otherTools.h index 80d9582a8..9316785d2 100644 --- a/src/tools/otherTools.h +++ b/src/tools/otherTools.h @@ -78,6 +78,9 @@ namespace kiwix Suggestions(); void add(const zim::SuggestionItem& suggestion); + + void addFTSearchSuggestion(const std::string& uiLang, + const std::string& query); }; } From abcd4ade9933a4d886efaa52f4622123e850eb7f Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 14:16:58 +0400 Subject: [PATCH 05/11] kiwix::Suggestions::getJSON() --- src/server/internalServer.cpp | 6 +----- src/tools/otherTools.cpp | 9 +++++++++ src/tools/otherTools.h | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 38ec37903..dd4c766b5 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -711,11 +711,7 @@ std::unique_ptr InternalServer::handle_suggest(const RequestContext& r results.addFTSearchSuggestion(request.get_user_language(), queryString); } - auto data = get_default_data(); - data.set("suggestions", results); - - auto response = ContentResponse::build(*this, RESOURCE::templates::suggestion_json, data, "application/json; charset=utf-8"); - return std::move(response); + return ContentResponse::build(*this, results.getJSON(), "application/json; charset=utf-8"); } std::unique_ptr InternalServer::handle_viewer_settings(const RequestContext& request) diff --git a/src/tools/otherTools.cpp b/src/tools/otherTools.cpp index 282c604f1..b7606565f 100644 --- a/src/tools/otherTools.cpp +++ b/src/tools/otherTools.cpp @@ -33,6 +33,7 @@ #include "tools/stringTools.h" #include "server/i18n.h" +#include "libkiwix-resources.h" #include #include @@ -375,3 +376,11 @@ void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang, result.set("first", this->is_empty_list()); this->push_back(result); } + +std::string kiwix::Suggestions::getJSON() const +{ + kainjow::mustache::data data; + data.set("suggestions", *this); + + return render_template(RESOURCE::templates::suggestion_json, data); +} diff --git a/src/tools/otherTools.h b/src/tools/otherTools.h index 9316785d2..e9963d08a 100644 --- a/src/tools/otherTools.h +++ b/src/tools/otherTools.h @@ -81,6 +81,8 @@ namespace kiwix void addFTSearchSuggestion(const std::string& uiLang, const std::string& query); + + std::string getJSON() const; }; } From da78aae62b7e04ea65030d7c01abfe43d7c284dc Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 14:20:57 +0400 Subject: [PATCH 06/11] kiwix::Suggestions gives up its temporary pedigree --- src/tools/otherTools.cpp | 12 ++++++------ src/tools/otherTools.h | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/tools/otherTools.cpp b/src/tools/otherTools.cpp index b7606565f..1445de5c1 100644 --- a/src/tools/otherTools.cpp +++ b/src/tools/otherTools.cpp @@ -346,7 +346,7 @@ std::string makeFulltextSearchSuggestion(const std::string& lang, } // unnamed namespace kiwix::Suggestions::Suggestions() - : kainjow::mustache::data(kainjow::mustache::data::type::list) + : m_data(kainjow::mustache::data::type::list) { } @@ -362,8 +362,8 @@ void kiwix::Suggestions::add(const zim::SuggestionItem& suggestion) result.set("value", suggestion.getTitle()); result.set("kind", "path"); result.set("path", suggestion.getPath()); - result.set("first", this->is_empty_list()); - this->push_back(result); + result.set("first", m_data.is_empty_list()); + m_data.push_back(result); } void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang, @@ -373,14 +373,14 @@ void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang, result.set("label", makeFulltextSearchSuggestion(uiLang, queryString)); result.set("value", queryString + " "); result.set("kind", "pattern"); - result.set("first", this->is_empty_list()); - this->push_back(result); + result.set("first", m_data.is_empty_list()); + m_data.push_back(result); } std::string kiwix::Suggestions::getJSON() const { kainjow::mustache::data data; - data.set("suggestions", *this); + data.set("suggestions", m_data); return render_template(RESOURCE::templates::suggestion_json, data); } diff --git a/src/tools/otherTools.h b/src/tools/otherTools.h index e9963d08a..1338eb752 100644 --- a/src/tools/otherTools.h +++ b/src/tools/otherTools.h @@ -72,7 +72,7 @@ namespace kiwix return defaultValue; } - class Suggestions : public kainjow::mustache::data + class Suggestions { public: Suggestions(); @@ -83,6 +83,9 @@ namespace kiwix const std::string& query); std::string getJSON() const; + + private: + kainjow::mustache::data m_data; }; } From 0f0ae1cfed6aa4d9c7eea5af9a01d58eb4fafe99 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 15:44:14 +0400 Subject: [PATCH 07/11] A small refactoring --- src/tools/otherTools.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/otherTools.cpp b/src/tools/otherTools.cpp index 1445de5c1..3d9fd78bd 100644 --- a/src/tools/otherTools.cpp +++ b/src/tools/otherTools.cpp @@ -353,12 +353,12 @@ kiwix::Suggestions::Suggestions() void kiwix::Suggestions::add(const zim::SuggestionItem& suggestion) { kainjow::mustache::data result; - result.set("label", suggestion.getTitle()); - if (suggestion.hasSnippet()) { - result.set("label", suggestion.getSnippet()); - } + const std::string label = suggestion.hasSnippet() + ? suggestion.getSnippet() + : suggestion.getTitle(); + result.set("label", label); result.set("value", suggestion.getTitle()); result.set("kind", "path"); result.set("path", suggestion.getPath()); From c727de65913c80d78fb604f84057c4fe3db72184 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 17:21:30 +0400 Subject: [PATCH 08/11] Unit-testing of kiwix::Suggestions The new unit test fails because of a buggy mishandling of backslashes in suggestions. The fix is coming next. --- test/meson.build | 1 + test/otherTools.cpp | 174 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 test/otherTools.cpp diff --git a/test/meson.build b/test/meson.build index ac432ae00..772afda18 100644 --- a/test/meson.build +++ b/test/meson.build @@ -4,6 +4,7 @@ tests = [ 'tagParsing', 'stringTools', 'pathTools', + 'otherTools', 'kiwixserve', 'book', 'manager', diff --git a/test/otherTools.cpp b/test/otherTools.cpp new file mode 100644 index 000000000..cd02a6fed --- /dev/null +++ b/test/otherTools.cpp @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2022 Veloman Yunkan + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and + * NON-INFRINGEMENT. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "gtest/gtest.h" +#include "../src/tools/otherTools.h" +#include "zim/suggestion_iterator.h" + +#include + +namespace +{ + +// Output generated via mustache templates sometimes contains end-of-line +// whitespace. This complicates representing the expected output of a unit-test +// as C++ raw strings in editors that are configured to delete EOL whitespace. +// A workaround is to put special markers (//EOLWHITESPACEMARKER) at the end +// of such lines in the expected output string and remove them at runtime. +// This is exactly what this function is for. +std::string removeEOLWhitespaceMarkers(const std::string& s) +{ + const std::regex pattern("//EOLWHITESPACEMARKER"); + return std::regex_replace(s, pattern, ""); +} + +} // unnamed namespace + +#define CHECK_SUGGESTIONS(actual, expected) \ + EXPECT_EQ(actual, removeEOLWhitespaceMarkers(expected)) + +TEST(Suggestions, basicTest) +{ + kiwix::Suggestions s; + CHECK_SUGGESTIONS(s.getJSON(), +R"EXPECTEDJSON([ + //EOLWHITESPACEMARKER +] +)EXPECTEDJSON" + ); + + s.add(zim::SuggestionItem("Title", "/PATH", "Snippet")); + + CHECK_SUGGESTIONS(s.getJSON(), +R"EXPECTEDJSON([ + { + "value" : "Title", + "label" : "Snippet", + "kind" : "path" + , "path" : "/PATH" + } +] +)EXPECTEDJSON" + ); + + s.add(zim::SuggestionItem("Title Without Snippet", "/P/a/t/h")); + s.addFTSearchSuggestion("en", "kiwi"); + + CHECK_SUGGESTIONS(s.getJSON(), +R"EXPECTEDJSON([ + { + "value" : "Title", + "label" : "Snippet", + "kind" : "path" + , "path" : "/PATH" + }, + { + "value" : "Title Without Snippet", + "label" : "Title Without Snippet", + "kind" : "path" + , "path" : "/P/a/t/h" + }, + { + "value" : "kiwi ", + "label" : "containing 'kiwi'...", + "kind" : "pattern" + //EOLWHITESPACEMARKER + } +] +)EXPECTEDJSON" + ); +} + +TEST(Suggestions, specialCharHandling) +{ + // HTML special symbols (<, >, &, ", and ') must be HTML-escaped + // Backslash symbols (\) must be duplicated. + const std::string SPECIAL_CHARS(R"(\<>&'")"); + { + kiwix::Suggestions s; + s.add(zim::SuggestionItem("Title with " + SPECIAL_CHARS, + "Path with " + SPECIAL_CHARS, + "Snippet with " + SPECIAL_CHARS)); + + CHECK_SUGGESTIONS(s.getJSON(), +R"EXPECTEDJSON([ + { + "value" : "Title with \\<>&'"", + "label" : "Snippet with \\<>&'"", + "kind" : "path" + , "path" : "Path with \\<>&'"" + } +] +)EXPECTEDJSON" + ); + } + + { + kiwix::Suggestions s; + s.add(zim::SuggestionItem("Snippetless title with " + SPECIAL_CHARS, + "Path with " + SPECIAL_CHARS)); + + CHECK_SUGGESTIONS(s.getJSON(), +R"EXPECTEDJSON([ + { + "value" : "Snippetless title with \\<>&'"", + "label" : "Snippetless title with \\<>&'"", + "kind" : "path" + , "path" : "Path with \\<>&'"" + } +] +)EXPECTEDJSON" + ); + } + + { + kiwix::Suggestions s; + s.addFTSearchSuggestion("eng", "text with " + SPECIAL_CHARS); + + CHECK_SUGGESTIONS(s.getJSON(), +R"EXPECTEDJSON([ + { + "value" : "text with \\<>&'" ", + "label" : "containing 'text with \\<>&'"'...", + "kind" : "pattern" + //EOLWHITESPACEMARKER + } +] +)EXPECTEDJSON" + ); + } +} + +TEST(Suggestions, fulltextSearchSuggestionIsTranslated) +{ + kiwix::Suggestions s; + s.addFTSearchSuggestion("it", "kiwi"); + + CHECK_SUGGESTIONS(s.getJSON(), +R"EXPECTEDJSON([ + { + "value" : "kiwi ", + "label" : "contenente 'kiwi'...", + "kind" : "pattern" + //EOLWHITESPACEMARKER + } +] +)EXPECTEDJSON" + ); +} From 4966f4155dcfff93fb43cff791a4fa4e01f1943d Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 17:23:10 +0400 Subject: [PATCH 09/11] Fixed handling of backslashes in suggestions --- src/tools/otherTools.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/tools/otherTools.cpp b/src/tools/otherTools.cpp index 3d9fd78bd..37345e7d1 100644 --- a/src/tools/otherTools.cpp +++ b/src/tools/otherTools.cpp @@ -333,6 +333,19 @@ std::string kiwix::render_template(const std::string& template_str, kainjow::mus namespace { +std::string escapeBackslashes(const std::string& s) +{ + std::string es; + es.reserve(s.size()); + for (char c : s) { + if ( c == '\\' ) { + es.push_back('\\'); + } + es.push_back(c); + } + return es; +} + std::string makeFulltextSearchSuggestion(const std::string& lang, const std::string& queryString) { @@ -358,10 +371,10 @@ void kiwix::Suggestions::add(const zim::SuggestionItem& suggestion) ? suggestion.getSnippet() : suggestion.getTitle(); - result.set("label", label); - result.set("value", suggestion.getTitle()); + result.set("label", escapeBackslashes(label)); + result.set("value", escapeBackslashes(suggestion.getTitle())); result.set("kind", "path"); - result.set("path", suggestion.getPath()); + result.set("path", escapeBackslashes(suggestion.getPath())); result.set("first", m_data.is_empty_list()); m_data.push_back(result); } @@ -370,8 +383,9 @@ void kiwix::Suggestions::addFTSearchSuggestion(const std::string& uiLang, const std::string& queryString) { kainjow::mustache::data result; - result.set("label", makeFulltextSearchSuggestion(uiLang, queryString)); - result.set("value", queryString + " "); + const std::string label = makeFulltextSearchSuggestion(uiLang, queryString); + result.set("label", escapeBackslashes(label)); + result.set("value", escapeBackslashes(queryString + " ")); result.set("kind", "pattern"); result.set("first", m_data.is_empty_list()); m_data.push_back(result); From 7743e73edebf2f4eb06a6f91333d09b413be5d17 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 10 Nov 2022 17:24:57 +0400 Subject: [PATCH 10/11] All non-alphanumeric symbols deserve a test --- test/otherTools.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/otherTools.cpp b/test/otherTools.cpp index cd02a6fed..221c2ac30 100644 --- a/test/otherTools.cpp +++ b/test/otherTools.cpp @@ -99,20 +99,20 @@ TEST(Suggestions, specialCharHandling) { // HTML special symbols (<, >, &, ", and ') must be HTML-escaped // Backslash symbols (\) must be duplicated. - const std::string SPECIAL_CHARS(R"(\<>&'")"); + const std::string SYMBOLS(R"(\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?)"); { kiwix::Suggestions s; - s.add(zim::SuggestionItem("Title with " + SPECIAL_CHARS, - "Path with " + SPECIAL_CHARS, - "Snippet with " + SPECIAL_CHARS)); + s.add(zim::SuggestionItem("Title with " + SYMBOLS, + "Path with " + SYMBOLS, + "Snippet with " + SYMBOLS)); CHECK_SUGGESTIONS(s.getJSON(), R"EXPECTEDJSON([ { - "value" : "Title with \\<>&'"", - "label" : "Snippet with \\<>&'"", + "value" : "Title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?", + "label" : "Snippet with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?", "kind" : "path" - , "path" : "Path with \\<>&'"" + , "path" : "Path with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?" } ] )EXPECTEDJSON" @@ -121,16 +121,16 @@ R"EXPECTEDJSON([ { kiwix::Suggestions s; - s.add(zim::SuggestionItem("Snippetless title with " + SPECIAL_CHARS, - "Path with " + SPECIAL_CHARS)); + s.add(zim::SuggestionItem("Snippetless title with " + SYMBOLS, + "Path with " + SYMBOLS)); CHECK_SUGGESTIONS(s.getJSON(), R"EXPECTEDJSON([ { - "value" : "Snippetless title with \\<>&'"", - "label" : "Snippetless title with \\<>&'"", + "value" : "Snippetless title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?", + "label" : "Snippetless title with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?", "kind" : "path" - , "path" : "Path with \\<>&'"" + , "path" : "Path with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?" } ] )EXPECTEDJSON" @@ -139,13 +139,13 @@ R"EXPECTEDJSON([ { kiwix::Suggestions s; - s.addFTSearchSuggestion("eng", "text with " + SPECIAL_CHARS); + s.addFTSearchSuggestion("eng", "text with " + SYMBOLS); CHECK_SUGGESTIONS(s.getJSON(), R"EXPECTEDJSON([ { - "value" : "text with \\<>&'" ", - "label" : "containing 'text with \\<>&'"'...", + "value" : "text with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.? ", + "label" : "containing 'text with \\<>&'"~!@#$%^*()_+`-=[]{}|:;,.?'...", "kind" : "pattern" //EOLWHITESPACEMARKER } From d66cc6286c01c658488f8bee5cd76f6a44b8ce56 Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Thu, 17 Nov 2022 11:32:38 +0100 Subject: [PATCH 11/11] Fix broken macOS CI (change Python version) --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24c95e581..20410c465 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,14 +12,14 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Setup python 3.10 - uses: actions/setup-python@v2 + - name: Setup python 3.9 + uses: actions/setup-python@v1 with: - python-version: '3.10' + python-version: '3.9' - name: Install packages run: | brew update - brew install gcovr pkg-config ninja + brew install gcovr pkg-config ninja || brew link --overwrite python - name: Install python modules run: pip3 install meson==0.49.2 pytest - name: Install deps