Bug 17038: Fix XSS in catalogue/search.pl
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 3 Aug 2016 12:57:43 +0000 (13:57 +0100)
committerChris Cormack <chris@bigballofwax.co.nz>
Mon, 22 Aug 2016 19:39:34 +0000 (07:39 +1200)
Test plan:
Search for something like:
  \";alert(1)//135

=> Without this patch you will see the alert
=> With this patch, no more alert

Note that this fix the parameters idx, q and op

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt

index a599a9f..0c1028f 100644 (file)
@@ -131,7 +131,7 @@ $('#sort_by').change(function() {
     $(".selection").show();
     [% IF ( query_desc ) %]
     toHighlight = $("p,span.results_summary,a.title");
-        var query_desc = "[% query_desc |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
+        var query_desc = "[% query_desc |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
         q_array = query_desc.split(" ");
         // ensure that we don't have "" at the end of the array, which can
         // break the highlighter