diff --git a/static/skin/viewer.js b/static/skin/viewer.js
index 50d91ea6c..9571b1eea 100644
--- a/static/skin/viewer.js
+++ b/static/skin/viewer.js
@@ -56,6 +56,16 @@ function performSearch() {
gotoUrl(`/search?books.name=${currentBook}&pattern=${q}`);
}
+function makeJSLink(jsCodeString, linkText, linkAttr="") {
+ // Values of the href attribute are assumed by the browser to be
+ // fully URI-encoded (no matter what the scheme is). Therefore, in
+ // order to prevent the browser from decoding any URI-encoded parts
+ // in the JS code we have to URI-encode a second time.
+ // (see https://stackoverflow.com/questions/33721510)
+ const uriEncodedJSCode = encodeURIComponent(jsCodeString);
+ return `${linkText}`;
+}
+
function suggestionsApiURL()
{
return `${root}/suggest?content=${encodeURIComponent(currentBook)}`;
@@ -343,13 +353,8 @@ function setupSuggestions() {
searchLink = `/search?content=${encodeURIComponent(currentBook)}&pattern=${encodeURIComponent(htmlDecode(data.value.value))}`;
}
const jsAction = `gotoUrl('${searchLink}')`;
- // Values of the href attribute are assumed by the browser to be
- // fully URI-encoded (no matter what the scheme is). Therefore, in
- // order to prevent the browser from decoding the URI-encoded parts
- // of searchLink we have to URI-encode a second time.
- // (see https://stackoverflow.com/questions/33721510)
- const jsActionURIEncoded = encodeURIComponent(jsAction);
- item.innerHTML = `${htmlDecode(data.value.label)}`;
+ const linkText = htmlDecode(data.value.label);
+ item.innerHTML = makeJSLink(jsAction, linkText, 'class="suggest"');
},
highlight: "autoComplete_highlight",
selected: "autoComplete_selected"
diff --git a/test/server.cpp b/test/server.cpp
index c757be4b6..a166fa0ae 100644
--- a/test/server.cpp
+++ b/test/server.cpp
@@ -69,7 +69,7 @@ const ResourceCollection resources200Compressible{
{ DYNAMIC_CONTENT, "/ROOT/skin/taskbar.css" },
{ STATIC_CONTENT, "/ROOT/skin/taskbar.css?cacheid=216d6b5d" },
{ DYNAMIC_CONTENT, "/ROOT/skin/viewer.js" },
- { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=fa85ec82" },
+ { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=e250a5c9" },
{ DYNAMIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf" },
{ STATIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf?cacheid=af705837" },
{ DYNAMIC_CONTENT, "/ROOT/skin/fonts/Roboto.ttf" },
@@ -291,7 +291,7 @@ R"EXPECTEDRESULT(
-
+
const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032";