about summary refs log tree commit diff stats
path: root/src/reader.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.js')
-rw-r--r--src/reader.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/reader.js b/src/reader.js
index a45ce9c..a3b81b7 100644
--- a/src/reader.js
+++ b/src/reader.js
@@ -242,7 +242,7 @@ class ReaderClass extends AppCommon {
 
                 console.error(err);
 
-                $(".loading-message").html(`Unable to load book info.<br/><small>${this.escapeHtml(err.responseText)}</small>`);
+                $(".loading-message").html(`Unable to load book info.<br/><small>${this.escapeHtml((String)(err.responseText))}</small>`);
                 return;
             }
         }
@@ -582,7 +582,7 @@ class ReaderClass extends AppCommon {
                     });
 
                     if (toc_entry && toc_entry.label)
-                        $(".chapter_title").html(toc_entry.label.trim() + " | ");
+                        $(".chapter_title").text(this.escapeHtml(toc_entry.label.trim()) + " | ");
 
                     this.generateTocBar(book, this.flattenToc(book));
                 }
@@ -735,9 +735,12 @@ class ReaderClass extends AppCommon {
 
         $('#dict-modal').on('shown.bs.modal', () => {
             $(".dict_query")
-                .off("change")
-                .on("change", () => {
-                    this.lookupWord(null, null, '.dict_query');
+                .off("keyup")
+                .on("keyup", (evt) => {
+                    if (evt.which === 13) {
+                        evt.preventDefault();
+                        this.lookupWord(null, null, '.dict_query');
+                    }
                 });
 
             $(".dict_result").scrollTop(0);
@@ -792,7 +795,7 @@ class ReaderClass extends AppCommon {
 
                     const a = $("<a>")
                         .attr('href', '#')
-                        .html("<b class='pull-right'>" + toc_loc_msg(row.href) + "</b>" + row.label)
+                        .html("<b class='pull-right'>" + toc_loc_msg(row.href) + "</b>" + _reader.escapeHtml(row.label))
                         .attr('data-href', row.href)
                         .click(function() {
                             book.rendition.display(a.attr('data-href'));
@@ -821,7 +824,7 @@ class ReaderClass extends AppCommon {
                 try {
                     const a = $("<a>")
                         .attr('href', '#')
-                        .html("<b class='pull-right'>" + toc_loc_msg(row.href) + "</b>" + row.label)
+                        .html("<b class='pull-right'>" + toc_loc_msg(row.href) + "</b>" + _reader.escapeHtml(row.label))
                         .attr('data-href', row.href)
                         .click(function() {
                             book.rendition.display(a.attr('data-href'));
@@ -1395,7 +1398,7 @@ class ReaderClass extends AppCommon {
 
             if (data.data) {
 
-                $(".dict_result").html(data.data.result.join("<br/>"));
+                $(".dict_result").html(data.data.result.map((r) => this.escapeHtml(String(r))).join("<br/>"));
                 $(".dict_query").val(word);
 
                 if (callback) callback();
@@ -1406,7 +1409,7 @@ class ReaderClass extends AppCommon {
 
             console.error(err);
 
-            $(".dict_result").html(`Network error while looking up word: ${this.escapeHtml(err.responseText)}.`);
+            $(".dict_result").html(`Network error while looking up word: ${this.escapeHtml((String)(err.responseText))}.`);
         }
     }