mirror of https://github.com/kiwix/libkiwix.git
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)
This commit is contained in:
parent
d4db090bb9
commit
3052d0787a
|
@ -81,7 +81,7 @@ kainjow::mustache::object getSingleBookData(const Book& book)
|
||||||
{"title", book.getTitle()},
|
{"title", book.getTitle()},
|
||||||
{"description", book.getDescription()},
|
{"description", book.getDescription()},
|
||||||
{"language", book.getLanguage()},
|
{"language", book.getLanguage()},
|
||||||
{"content_id", book.getHumanReadableIdFromPath()},
|
{"content_id", urlEncode(book.getHumanReadableIdFromPath(), true)},
|
||||||
{"updated", book.getDate() + "T00:00:00Z"},
|
{"updated", book.getDate() + "T00:00:00Z"},
|
||||||
{"category", book.getCategory()},
|
{"category", book.getCategory()},
|
||||||
{"flavour", book.getFlavour()},
|
{"flavour", book.getFlavour()},
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
></book>
|
></book>
|
||||||
<book
|
<book
|
||||||
id="charlesray"
|
id="charlesray"
|
||||||
path="./zimfile.zim"
|
path="./zimfile&other.zim"
|
||||||
url="https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile.zim"
|
url="https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile%26other.zim"
|
||||||
title="Charles, Ray"
|
title="Charles, Ray"
|
||||||
description="Wikipedia articles about Ray Charles"
|
description="Wikipedia articles about Ray Charles"
|
||||||
language="fra"
|
language="fra"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
zimfile.zim
|
|
@ -29,6 +29,7 @@ if gtest_dep.found() and not meson.is_cross_build()
|
||||||
data_files = [
|
data_files = [
|
||||||
'example.zim',
|
'example.zim',
|
||||||
'zimfile.zim',
|
'zimfile.zim',
|
||||||
|
'zimfile&other.zim',
|
||||||
'corner_cases.zim',
|
'corner_cases.zim',
|
||||||
'library.xml'
|
'library.xml'
|
||||||
]
|
]
|
||||||
|
|
|
@ -701,14 +701,14 @@ std::string maskVariableOPDSFeedData(std::string s)
|
||||||
" <tags>unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
|
" <tags>unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
|
||||||
" <articleCount>284</articleCount>\n" \
|
" <articleCount>284</articleCount>\n" \
|
||||||
" <mediaCount>2</mediaCount>\n" \
|
" <mediaCount>2</mediaCount>\n" \
|
||||||
" <link type=\"text/html\" href=\"/ROOT/zimfile\" />\n" \
|
" <link type=\"text/html\" href=\"/ROOT/zimfile%26other\" />\n" \
|
||||||
" <author>\n" \
|
" <author>\n" \
|
||||||
" <name>Wikipedia</name>\n" \
|
" <name>Wikipedia</name>\n" \
|
||||||
" </author>\n" \
|
" </author>\n" \
|
||||||
" <publisher>\n" \
|
" <publisher>\n" \
|
||||||
" <name>Kiwix</name>\n" \
|
" <name>Kiwix</name>\n" \
|
||||||
" </publisher>\n" \
|
" </publisher>\n" \
|
||||||
" <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile.zim\" length=\"569344\" />\n" \
|
" <link rel=\"http://opds-spec.org/acquisition/open-access\" type=\"application/x-zim\" href=\"https://github.com/kiwix/libkiwix/raw/master/test/data/zimfile%26other.zim\" length=\"569344\" />\n" \
|
||||||
" </entry>\n"
|
" </entry>\n"
|
||||||
|
|
||||||
#define RAY_CHARLES_CATALOG_ENTRY \
|
#define RAY_CHARLES_CATALOG_ENTRY \
|
||||||
|
|
Loading…
Reference in New Issue