From ae47583e2d0e5ef546d6869f2ff5104f7911d68f Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 20 Apr 2020 18:40:22 +0200 Subject: Fix searh for terms and results including HTML chars --- htdocs/mapscript.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js index e450af9..8aab466 100644 --- a/htdocs/mapscript.js +++ b/htdocs/mapscript.js @@ -256,7 +256,7 @@ function polyline_get_middle_coords(coords) { var highlighted_line; var default_street_color = "#3388ff"; function search(e) { - var query = htmlEntities(document.getElementById("search_query").value); + var query = document.getElementById("search_query").value; document.getElementById('search_results').innerHTML = ""; if (query.length > 0 || e.key == "Enter") { results = document.createElement("ul"); @@ -271,7 +271,7 @@ function search(e) { regex = new RegExp(query, 'i'); if (item.feature.properties.name.match(regex)) { el = document.createElement("li"); - el.innerHTML = "[" + layers._layers[i].name + "] " + '' + item.feature.properties.name + ""; + el.innerHTML = "[" + layers._layers[i].name + "] " + '' + htmlEntities(item.feature.properties.name) + ""; results.appendChild(el); } break; @@ -283,12 +283,11 @@ function search(e) { regex = new RegExp(query, 'i'); if (item.feature.properties.name.match(regex)) { - console.log(item.options.color); item.options.color = "#FF0000"; item.redraw(); el = document.createElement("li"); zpos = polyline_get_middle_coords(item.feature.geometry.coordinates); - el.innerHTML = "[" + layers._layers[i].name + "] " + '' + item.feature.properties.name + ""; + el.innerHTML = "[" + layers._layers[i].name + "] " + '' + htmlEntities(item.feature.properties.name) + ""; results.appendChild(el); } break; -- cgit v1.2.3