From bac12010aafa77f5a18f489c947655c9098705c2 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sat, 7 Jan 2023 14:40:43 +0400 Subject: [PATCH 1/4] Updated create_corner_cases_zim_file script Updated the create_corner_cases_zim_file to work with the latest (v3.1.3) release of zimwriterfs. --- test/data/corner_cases.zim | Bin 75741 -> 2933 bytes test/data/create_corner_cases_zim_file | 5 +++-- test/server.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/data/corner_cases.zim b/test/data/corner_cases.zim index 650c1d9622d8729c5d6912e38935194c4c6842dd..4e5a348af45e85f94286adaf24b1f7a4b4ef7bb9 100644 GIT binary patch literal 2933 zcmeHJ-Afcv6u;)IWty!Jy%Y)c5|vGs*n)=9t`FizhMP$r=ykpBj?B)EGk0aHmq3Id ziA3ljdI%IXgFcW7>R}(OOv<31dI~iolENT~f?_)7&TUZ%`UmF1Z+~a+Irp4%&z*) zwM?CA#xk=!5~G&Q_@N~4C=SSuJn|;sO~9LgHvw+~-UR+P0pHI1>TeQb3fVqYw8N}g z_~kewAD_<~`l&a5|G?u`rD*c&)X#pUt>)FDb5Ql|xjD9_q-^-kmx~|fw~Y@pZN2w- z@@`e{XiwMXhh@X>8b^;c4_4H_Z@z36PjuB>iqaQ@p;&%%*3Zne7p8MvLV#d+#)oBGUniV` zhJ*)`BU}#(8SJkPcErM-f{CQTnI)ReIPgM2P(wVi%7M2EQO;I|d#M17G9 zYvZcc^(4qEA;MZp1F6!$;gXdpFshas(IhCYl^)E|kZc1@7F*pW&bl#TQFFBeA0SMl zFbS|Sx5~y{jq6aramWeyCx#OT3D+RXLMeP&v5O;+I#A_!=&04sEY_}e?-K!;K+O8@ zK)B*JDN+mYePHd99Fp83IVHJY@`&Uok{2W^Qv4Q44oI$-%p{+eJS16sictTm?8jI8 Sbm_>F{c^4%Tu_yN?fV}kv*&35 literal 75741 zcmeI*eTWog9KiA4?CtHnZ1)-kVl`K&A#!(~f23GfT!xpWCV1c_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YIu zu4RTBEgUhaO4LDo{0B2CztHz_JQ2s{nU(ymI4+H&7stEf_+%V+#qr}f{usx9;&{QV zN_!n~TpY(WaV*90#W+qpbAw`jV1*LHX?{=RZ3xZfU@ky&&6-QvTu@EAHS5-*TdQtS dWes~wBl_vt-SWg`?~Pxwzi-vFcdh##_!pV~iE;n{ diff --git a/test/data/create_corner_cases_zim_file b/test/data/create_corner_cases_zim_file index 9462a63ea..93c8793ba 100755 --- a/test/data/create_corner_cases_zim_file +++ b/test/data/create_corner_cases_zim_file @@ -2,8 +2,9 @@ cd "$(dirname "$0")" rm -f corner_cases.zim -zimwriterfs -w empty.html \ - -f empty.png \ +zimwriterfs --withoutFTIndex --dont-check-arguments \ + -w empty.html \ + -I empty.png \ -l=en \ -t="ZIM corner cases" \ -d="" \ diff --git a/test/server.cpp b/test/server.cpp index 0780a3949..bc53fb8d7 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -157,9 +157,9 @@ const ResourceCollection resources200Uncompressible{ { ZIM_CONTENT, "/ROOT/content/zimfile/I/m/Ray_Charles_classic_piano_pose.jpg" }, - { ZIM_CONTENT, "/ROOT/content/corner_cases/A/empty.html" }, - { ZIM_CONTENT, "/ROOT/content/corner_cases/-/empty.css" }, - { ZIM_CONTENT, "/ROOT/content/corner_cases/-/empty.js" }, + { ZIM_CONTENT, "/ROOT/content/corner_cases/empty.html" }, + { ZIM_CONTENT, "/ROOT/content/corner_cases/empty.css" }, + { ZIM_CONTENT, "/ROOT/content/corner_cases/empty.js" }, // The following url's responses are too small to be compressed @@ -1507,7 +1507,7 @@ TEST_F(ServerTest, InvalidAndMultiRangeByteRangeRequestsResultIn416Responses) TEST_F(ServerTest, ValidByteRangeRequestsOfZeroSizedEntriesResultIn416Responses) { - const char url[] = "/ROOT/content/corner_cases/-/empty.js"; + const char url[] = "/ROOT/content/corner_cases/empty.js"; const char* ranges[] = { "bytes=0-", From 497c0700b51bfa8b1f2e0d29bed83b219796ffbf Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sat, 7 Jan 2023 15:05:13 +0400 Subject: [PATCH 2/4] Fixed metadata options in create_corner_cases_zim_file Specifying the = symbol with single-character options makes that character included in the option value (e.g. -l=en results in the language of the ZIM file being set to =en). --- test/data/corner_cases.zim | Bin 2933 -> 2805 bytes test/data/create_corner_cases_zim_file | 10 +++++----- test/server.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/data/corner_cases.zim b/test/data/corner_cases.zim index 4e5a348af45e85f94286adaf24b1f7a4b4ef7bb9..b13d0fe71b835f812de802782a26e686a8c8a733 100644 GIT binary patch delta 471 zcmew=_Epp?%F~yHje(ItdCiAxrwyBOwL14Mo&9>w7d{3C1|}d*{QqJ9hyOqIf5>w%Gc4s66lX{%{m#cI z0(2A%`vBPilUHz93o-&(%nS_9Kne`lCvi$KvQC!flxAd`Y|d%I$T2yGQ-Xs9DCv?| zk~;YirynEJWF0OEaiA`Ski_(21_m|;249G71_s8-(OgCKcc20D9ZCyxLgaO!v1R;-FO(LB2DlBBW`Nq$4WR`YuFaS8Z8mnj_)W|0xl#%D69D}9 BZ;Su{ delta 681 zcmew=`c=#;%F~yHje(INy(eM+X6qYEQWj(#oAbWnhadw30}~LRZ0|OfagD+SSkN}0Hb5Uwy zNj{ncJ5a(Uu_P5$InY)Hm(=3qqRfJl%>2B`rJR1=AcqE&Cgo%nXP}$T3X}>?E=nvw zmjF6}AtW&!=nrJaFi-x>SycZS8l`-kKt({H1*Kh}bUc)aq>X2zrn$_p%7pE`9XCB#v@VWBL`UU_bij{N# diff --git a/test/data/create_corner_cases_zim_file b/test/data/create_corner_cases_zim_file index 93c8793ba..5f11096a2 100755 --- a/test/data/create_corner_cases_zim_file +++ b/test/data/create_corner_cases_zim_file @@ -5,11 +5,11 @@ rm -f corner_cases.zim zimwriterfs --withoutFTIndex --dont-check-arguments \ -w empty.html \ -I empty.png \ - -l=en \ - -t="ZIM corner cases" \ - -d="" \ - -c="" \ - -p="" \ + -l en \ + -t "ZIM corner cases" \ + -d "" \ + -c "" \ + -p "" \ corner_cases \ corner_cases.zim \ && echo 'corner_cases.zim was successfully created' \ diff --git a/test/server.cpp b/test/server.cpp index bc53fb8d7..129e8af33 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -78,7 +78,6 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT/catalog/search" }, { DYNAMIC_CONTENT, "/ROOT/catalog/v2/root.xml" }, - { DYNAMIC_CONTENT, "/ROOT/catalog/v2/languages" }, { DYNAMIC_CONTENT, "/ROOT/catalog/v2/entries" }, { DYNAMIC_CONTENT, "/ROOT/catalog/v2/partial_entries" }, @@ -150,6 +149,7 @@ const ResourceCollection resources200Uncompressible{ { DYNAMIC_CONTENT, "/ROOT/catalog/searchdescription.xml" }, { DYNAMIC_CONTENT, "/ROOT/catalog/v2/categories" }, + { DYNAMIC_CONTENT, "/ROOT/catalog/v2/languages" }, { DYNAMIC_CONTENT, "/ROOT/catalog/v2/searchdescription.xml" }, { DYNAMIC_CONTENT, "/ROOT/catalog/v2/illustration/6f1d19d0-633f-087b-fb55-7ac324ff9baf?size=48" }, From 78b2c1a273620b0afdd4e251b6feb0e10f6486b0 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sat, 7 Jan 2023 15:43:30 +0400 Subject: [PATCH 3/4] Testing of redirection to URLs with special symbols --- test/data/corner_cases.zim | Bin 2805 -> 35912 bytes test/data/corner_cases/wtf.html | 1 + test/data/corner_cases/wtf? | 1 + test/data/corner_cases/wtf?.html | 11 +++++++++++ test/server.cpp | 11 +++++++++++ 5 files changed, 24 insertions(+) create mode 120000 test/data/corner_cases/wtf.html create mode 120000 test/data/corner_cases/wtf? create mode 100644 test/data/corner_cases/wtf?.html diff --git a/test/data/corner_cases.zim b/test/data/corner_cases.zim index b13d0fe71b835f812de802782a26e686a8c8a733..024d34d92b8e8932e68632ca63584a054dc4e1ae 100644 GIT binary patch literal 35912 zcmeI5f6QgYS;x<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oBXFshZpF!2#_9- z8<{4@bxX1s06CL2yH)EA85r(BW9d7T76y3_2y~&e2b4~P(&bQkE|lI5r7u9~XHfbt nlop1@z73QH`x$6{H_$#%I5S+EFX!8A?0WH=mfLfs67DAe#QcOs diff --git a/test/data/corner_cases/wtf.html b/test/data/corner_cases/wtf.html new file mode 120000 index 000000000..2a9593de8 --- /dev/null +++ b/test/data/corner_cases/wtf.html @@ -0,0 +1 @@ +wtf?.html \ No newline at end of file diff --git a/test/data/corner_cases/wtf? b/test/data/corner_cases/wtf? new file mode 120000 index 000000000..2a9593de8 --- /dev/null +++ b/test/data/corner_cases/wtf? @@ -0,0 +1 @@ +wtf?.html \ No newline at end of file diff --git a/test/data/corner_cases/wtf?.html b/test/data/corner_cases/wtf?.html new file mode 100644 index 000000000..75b47246a --- /dev/null +++ b/test/data/corner_cases/wtf?.html @@ -0,0 +1,11 @@ + + + + + WTF? + + +

WTF? is an acronym coined by cryptography and security researcher Walter + Thomas Freiwald. It stands for "Will They Factorize?"

+ + diff --git a/test/server.cpp b/test/server.cpp index 129e8af33..d53978691 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -1196,6 +1196,17 @@ TEST_F(ServerTest, NonEndpointUrlsAreRedirectedToContentUrls) } } +TEST_F(ServerTest, RedirectionsToURLsWithSpecialSymbols) +{ + auto g = zfs1_->GET("/ROOT/content/corner_cases/wtf.html"); + ASSERT_EQ(302, g->status); + ASSERT_TRUE(g->has_header("Location")); + ASSERT_EQ(g->get_header_value("Location"), "/ROOT/content/corner_cases/wtf?.html"); + ASSERT_EQ(getCacheControlHeader(*g), "max-age=0, must-revalidate"); + ASSERT_FALSE(g->has_header("ETag")); +} + + TEST_F(ServerTest, BookMainPageIsRedirectedToArticleIndex) { { From 8eb527389e204b75888ff467e41c46044e0c0ab9 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Sat, 7 Jan 2023 15:45:33 +0400 Subject: [PATCH 4/4] URI-encoding of redirections to URLs with special symbols --- src/server/internalServer.cpp | 2 +- test/server.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index dd4c766b5..0edb367fc 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -1030,7 +1030,7 @@ ParameterizedMessage suggestSearchMsg(const std::string& searchURL, const std::s std::unique_ptr InternalServer::build_redirect(const std::string& bookName, const zim::Item& item) const { - const auto path = kiwix::urlEncode(item.getPath()); + const auto path = kiwix::urlEncode(item.getPath(), true); const auto redirectUrl = m_root + "/content/" + bookName + "/" + path; return Response::build_redirect(*this, redirectUrl); } diff --git a/test/server.cpp b/test/server.cpp index d53978691..9d955bc2a 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -1145,7 +1145,7 @@ TEST_F(ServerTest, RandomPageRedirectsToAnExistingArticle) auto g = zfs1_->GET("/ROOT/random?content=zimfile"); ASSERT_EQ(302, g->status); ASSERT_TRUE(g->has_header("Location")); - ASSERT_TRUE(kiwix::startsWith(g->get_header_value("Location"), "/ROOT/content/zimfile/A/")); + ASSERT_TRUE(kiwix::startsWith(g->get_header_value("Location"), "/ROOT/content/zimfile/A%2F")); ASSERT_EQ(getCacheControlHeader(*g), "max-age=0, must-revalidate"); ASSERT_FALSE(g->has_header("ETag")); } @@ -1201,7 +1201,7 @@ TEST_F(ServerTest, RedirectionsToURLsWithSpecialSymbols) auto g = zfs1_->GET("/ROOT/content/corner_cases/wtf.html"); ASSERT_EQ(302, g->status); ASSERT_TRUE(g->has_header("Location")); - ASSERT_EQ(g->get_header_value("Location"), "/ROOT/content/corner_cases/wtf?.html"); + ASSERT_EQ(g->get_header_value("Location"), "/ROOT/content/corner_cases/wtf%3F.html"); ASSERT_EQ(getCacheControlHeader(*g), "max-age=0, must-revalidate"); ASSERT_FALSE(g->has_header("ETag")); } @@ -1213,7 +1213,7 @@ TEST_F(ServerTest, BookMainPageIsRedirectedToArticleIndex) auto g = zfs1_->GET("/ROOT/content/zimfile"); ASSERT_EQ(302, g->status); ASSERT_TRUE(g->has_header("Location")); - ASSERT_EQ("/ROOT/content/zimfile/A/index", g->get_header_value("Location")); + ASSERT_EQ("/ROOT/content/zimfile/A%2Findex", g->get_header_value("Location")); } }