From 04d682486a4df4dd47113648d2d910902d2ea138 Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Wed, 2 Mar 2022 00:21:24 +0530 Subject: [PATCH] Add some tests to emulate XSS attack --- test/server.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/server.cpp b/test/server.cpp index 3950f73c7..600b171ae 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -512,6 +512,30 @@ TEST_F(ServerTest, 404WithBodyTesting)

)" }, + { /* url */ R"(/ROOT/">)", + /* expected body */ R"( +

Not Found

+

+ The requested URL "/ROOT/"><svg onload=alert(1)>" was not found on this server. +

+

+ Make a full text search for "><svg onload=alert(1)> +

+)" }, + + { /* url */ R"(/ROOT/zimfile/">)", + /* book name */ "zimfile", + /* book title */ "Ray Charles", + /* expected body */ R"( +

Not Found

+

+ The requested URL "/ROOT/zimfile/"><svg onload=alert(1)>" was not found on this server. +

+

+ Make a full text search for "><svg onload=alert(1)> +

+)" }, + { /* url */ "/ROOT/raw/no-such-book/meta/Title", /* expected body */ R"(

Not Found