From 894ed12f37349c39a1e736bf4fb42d4d00164703 Mon Sep 17 00:00:00 2001 From: dattaz Date: Sat, 21 Oct 2017 13:17:13 +0200 Subject: [PATCH 1/2] escape the & character of humanReadableBookId to not be interpreted in urls as a new argument --- src/server/kiwix-serve.cpp | 5 ++--- static/server/include.html.part | 2 +- static/server/taskbar.html.part | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 32f2790..b75b5d1 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -162,9 +162,7 @@ void introduceTaskbar(string& content, const string& humanReadableBookId) content = appendToFirstOccurence( content, "", - replaceRegex( - RESOURCE::include_html_part, humanReadableBookId, "__CONTENT__") - + (noLibraryButtonFlag + RESOURCE::include_html_part + (noLibraryButtonFlag ? "" : "") ); @@ -183,6 +181,7 @@ void introduceTaskbar(string& content, const string& humanReadableBookId) "__CONTENT__")); } content = replaceRegex(content, rootLocation, "__ROOT_LOCATION__"); + content = replaceRegex(content,replaceRegex(humanReadableBookId, "%26", "&"), "__CONTENT_ESCAPE__"); } pthread_mutex_unlock(®exLock); } diff --git a/static/server/include.html.part b/static/server/include.html.part index 061ad4e..57d3ed4 100644 --- a/static/server/include.html.part +++ b/static/server/include.html.part @@ -8,7 +8,7 @@ jk(function() { jk( "#kiwixsearchbox" ).autocomplete({ - source: "__ROOT_LOCATION__/suggest?content=__CONTENT__", + source: "__ROOT_LOCATION__/suggest?content=__CONTENT_ESCAPE__", dataType: "json", cache: false, diff --git a/static/server/taskbar.html.part b/static/server/taskbar.html.part index ec367f5..7cc0972 100644 --- a/static/server/taskbar.html.part +++ b/static/server/taskbar.html.part @@ -4,7 +4,7 @@
- +
From 905b83b3b1e77ad59ee8bc45a064cf69a05d9c5d Mon Sep 17 00:00:00 2001 From: kelson42 Date: Wed, 8 Nov 2017 20:11:55 +0100 Subject: [PATCH 2/2] Small beautification of the code --- src/server/kiwix-serve.cpp | 2 +- static/server/include.html.part | 2 +- static/server/taskbar.html.part | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index b75b5d1..bed2c5f 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -181,7 +181,7 @@ void introduceTaskbar(string& content, const string& humanReadableBookId) "__CONTENT__")); } content = replaceRegex(content, rootLocation, "__ROOT_LOCATION__"); - content = replaceRegex(content,replaceRegex(humanReadableBookId, "%26", "&"), "__CONTENT_ESCAPE__"); + content = replaceRegex(content, replaceRegex(humanReadableBookId, "%26", "&"), "__CONTENT_ESCAPED__"); } pthread_mutex_unlock(®exLock); } diff --git a/static/server/include.html.part b/static/server/include.html.part index 57d3ed4..7996fcb 100644 --- a/static/server/include.html.part +++ b/static/server/include.html.part @@ -8,7 +8,7 @@ jk(function() { jk( "#kiwixsearchbox" ).autocomplete({ - source: "__ROOT_LOCATION__/suggest?content=__CONTENT_ESCAPE__", + source: "__ROOT_LOCATION__/suggest?content=__CONTENT_ESCAPED__", dataType: "json", cache: false, diff --git a/static/server/taskbar.html.part b/static/server/taskbar.html.part index 7cc0972..40967af 100644 --- a/static/server/taskbar.html.part +++ b/static/server/taskbar.html.part @@ -4,7 +4,7 @@