Proper URI-encoding in InternalServer::build_redirect()

- Before this change `InternalServer::build_redirect()` only URI-encoded the
  article path, ignoring the book name and/or the root location components of
  the URL.

- In order to be able to test this fix, corner_cases.zim was renamed to
  contain a couple of special URL symbols in its filename. The
  `create_corner_cases_zim_file` script was updated accordingly.
This commit is contained in:
Veloman Yunkan
2023-02-08 15:31:29 +01:00
parent 2f419996ab
commit 2e9bec95b0
7 changed files with 34 additions and 18 deletions

View File

@ -1030,9 +1030,8 @@ ParameterizedMessage suggestSearchMsg(const std::string& searchURL, const std::s
std::unique_ptr<Response>
InternalServer::build_redirect(const std::string& bookName, const zim::Item& item) const
{
const auto path = kiwix::urlEncode(item.getPath());
const auto redirectUrl = m_root + "/content/" + bookName + "/" + path;
return Response::build_redirect(*this, redirectUrl);
const auto absPath = m_root + "/content/" + bookName + "/" + item.getPath();
return Response::build_redirect(*this, kiwix::urlEncode(absPath));
}
std::unique_ptr<Response> InternalServer::handle_content(const RequestContext& request)