From 2d73ed31a9c58c09bf47cdedb5115746a0024dd0 Mon Sep 17 00:00:00 2001
From: Veloman Yunkan
- [I18N TESTING] URL not found: /ROOT%23%3F/content/zimfile/invalid-article -
-- [I18N TESTING] Make a full text search for invalid-article -
-)" }, - { /* url */ "/ROOT%23%3F/raw/no-such-book/meta/Title", expected_kiwix_response_data==R"({ "CSS_URL" : false, "PAGE_HEADING" : { "msgid" : "404-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "404-page-title", "params" : { } }, "details" : [ { "p" : { "msgid" : "url-not-found", "params" : { "url" : "/ROOT%23%3F/raw/no-such-book/meta/Title" } } }, { "p" : { "msgid" : "no-such-book", "params" : { "BOOK_NAME" : "no-such-book" } } } ] })" && expected_body==R"( @@ -932,8 +917,9 @@ std::string escapeJsString(std::string s) std::string expectedSexy404ErrorHtml(const std::string& url) { - const auto htmlSafeUrl = htmlEscape(url); - const auto jsSafeUrl = escapeJsString(url); + const auto urlWithoutQuery = replace(url, "\\?.*$", ""); + const auto htmlSafeUrl = htmlEscape(urlWithoutQuery); + const auto jsSafeUrl = escapeJsString(urlWithoutQuery); const std::string englishText[] = { "Page not found", @@ -947,7 +933,20 @@ std::string expectedSexy404ErrorHtml(const std::string& url) "This approach should help you locate the desired content, even if the original link isn't working properly." }; - const std::string* const t = englishText; + const std::string translatedText[] = { + "Page [I18N] not [TESTING] found", + "[I18N] Not found! [TESTING]", + "[I18N TESTING] Oops. Larry Page could not be reached. He may be on paternity leave.", + "[I18N TESTING] The requested path was not found (in fact, nothing was found instead, either):", + "Sh*t happens. [I18N TESTING] Take it easy!", + "[I18N TESTING] Try one of the following:", + "[I18N TESTING] Check the spelling of the URL path", + "[I18N TESTING] Press the dice button", + "Good luck! [I18N TESTING]" + }; + + const bool shouldTranslate = url.find("userlang=test") != std::string::npos; + const std::string* const t = shouldTranslate ? translatedText : englishText; return R"RAWSTRINGLITERAL( @@ -1004,7 +1003,9 @@ TEST_F(ServerTest, HttpSexy404HtmlError) // XXX: inside a valid/existing book/ZIM-file. However it makes sense // XXX: to preserve both cases. "/ROOT%23%3F/content/invalid-book/whatever", + "/ROOT%23%3F/content/invalid-book/whatever?userlang=test", "/ROOT%23%3F/content/zimfile/invalid-article", + "/ROOT%23%3F/content/zimfile/invalid-article?userlang=test", // malicious URLs R"(/ROOT%23%3F/content/">