From 3052d0787aecf2f9a576f2dd499fabe9fa2de803 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 1 Dec 2021 10:33:52 +0100 Subject: [PATCH] UrlEncode the `content_id`. The HumanReadableId can contains special char (`&`/`=`/...) As it is used as to create a url in the opds template, we must url encode it. - We don't need to encode the book id as it is a uuid, it never contains special char. - We don't need to encode the book url as it is read from the library and the url must already be correctly encoded in the library.xml. (tests modified accordingly) --- src/opds_dumper.cpp | 2 +- test/data/library.xml | 4 ++-- test/data/zimfile&other.zim | 1 + test/meson.build | 1 + test/server.cpp | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) create mode 120000 test/data/zimfile&other.zim diff --git a/src/opds_dumper.cpp b/src/opds_dumper.cpp index 32d8010ec..b42b682f9 100644 --- a/src/opds_dumper.cpp +++ b/src/opds_dumper.cpp @@ -81,7 +81,7 @@ kainjow::mustache::object getSingleBookData(const Book& book) {"title", book.getTitle()}, {"description", book.getDescription()}, {"language", book.getLanguage()}, - {"content_id", book.getHumanReadableIdFromPath()}, + {"content_id", urlEncode(book.getHumanReadableIdFromPath(), true)}, {"updated", book.getDate() + "T00:00:00Z"}, {"category", book.getCategory()}, {"flavour", book.getFlavour()}, diff --git a/test/data/library.xml b/test/data/library.xml index 579fb3848..0b305bf0c 100644 --- a/test/data/library.xml +++ b/test/data/library.xml @@ -35,8 +35,8 @@ > unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes\n" \ " 284\n" \ " 2\n" \ - " \n" \ + " \n" \ " \n" \ " Wikipedia\n" \ " \n" \ " \n" \ " Kiwix\n" \ " \n" \ - " \n" \ + " \n" \ " \n" #define RAY_CHARLES_CATALOG_ENTRY \