diff --git a/test/server.cpp b/test/server.cpp index cf7e0a46f..4a188619d 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -787,8 +787,6 @@ TEST_F(ServerTest, Http404HtmlError) )" }, { /* url */ R"(/ROOT%23%3F/content/">)", - // XXX: This test case suggests that KIWIX_RESPONSE_DATA - // XXX: must be HTML-encoded, too 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/content/\">" } } }, { "p" : { "msgid" : "suggest-search", "params" : { "PATTERN" : "\">", "SEARCH_URL" : "/ROOT%23%3F/search?pattern=%22%3E%3Csvg%20onload%3Dalert(1)%3E" } } } ] })" && expected_body==R"(

Not Found

@@ -803,8 +801,6 @@ TEST_F(ServerTest, Http404HtmlError) { /* url */ R"(/ROOT%23%3F/content/zimfile/">)", book_name=="zimfile" && book_title=="Ray Charles" && - // XXX: This test case suggests that KIWIX_RESPONSE_DATA - // XXX: must be HTML-encoded, too 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/content/zimfile/\">" } } }, { "p" : { "msgid" : "suggest-search", "params" : { "PATTERN" : "\">", "SEARCH_URL" : "/ROOT%23%3F/search?content=zimfile&pattern=%22%3E%3Csvg%20onload%3Dalert(1)%3E" } } } ] })" && expected_body==R"(

Not Found

@@ -816,6 +812,22 @@ TEST_F(ServerTest, Http404HtmlError)

)" }, + // XXX: This test case is against a "" string appearing inside + // XXX: javascript code that will confuse the HTML parser + { /* url */ R"(/ROOT%23%3F/content/zimfile/)", + book_name=="zimfile" && + book_title=="Ray Charles" && + 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/content/zimfile/" } } }, { "p" : { "msgid" : "suggest-search", "params" : { "PATTERN" : "script>", "SEARCH_URL" : "/ROOT%23%3F/search?content=zimfile&pattern=script%3E" } } } ] })" && + expected_body==R"( +

Not Found

+

+ The requested URL "/ROOT%23%3F/content/zimfile/</script>" was not found on this server. +

+

+ Make a full text search for script> +

+)" }, + { /* url */ "/ROOT%23%3F/content/zimfile/invalid-article?userlang=test", expected_page_title=="[I18N TESTING] Not Found - Try Again" && book_name=="zimfile" &&