From 36e4fd1ef520fba8e9b24575e95a9bdb031b2105 Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Sat, 3 Aug 2013 13:50:37 -0400 Subject: [PATCH] URI encode IDs before replacing them in URL. Fixes #290 --- .../modules/core/scripts/views/data-table/cell-ui.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main/webapp/modules/core/scripts/views/data-table/cell-ui.js b/main/webapp/modules/core/scripts/views/data-table/cell-ui.js index 0326c49ec..079b5d22b 100644 --- a/main/webapp/modules/core/scripts/views/data-table/cell-ui.js +++ b/main/webapp/modules/core/scripts/views/data-table/cell-ui.js @@ -105,7 +105,7 @@ DataTableCellUI.prototype._render = function() { .appendTo(divContent); if (service && (service.view) && (service.view.url)) { - a.attr("href", service.view.url.replace("{{id}}", match.id)); + a.attr("href", service.view.url.replace("{{id}}", encodeURIComponent(match.id))); } else if (ReconciliationManager.isFreebaseIdOrMid(r.identifierSpace)) { a.attr("href", "http://www.freebase.com/view" + match.id); } @@ -148,9 +148,8 @@ DataTableCellUI.prototype._render = function() { .text(candidate.name) .appendTo(li); - // TODO: replace view URL with local code? if ((service) && (service.view) && (service.view.url)) { - a.attr("href", service.view.url.replace("{{id}}", candidate.id)); + a.attr("href", service.view.url.replace("{{id}}", encodeURIComponent(candidate.id))); } else if (ReconciliationManager.isFreebaseIdOrMid(r.identifierSpace)) { a.attr("href", "http://www.freebase.com/view" + candidate.id); } @@ -454,14 +453,14 @@ DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, pre .html(DOM.loadHTML("core", "scripts/views/data-table/cell-recon-preview-popup-header.html")); if (preview && preview.url) { // Service has a preview URL associated with it - var url = preview.srch.replace("{{id}}", id); + var url = preview.srch.replace("{{id}}", encodeURIComponent(id)); var iframe = $('') .width(preview.width) .height(preview.height) .attr("src", url) .appendTo(fakeMenu); } else { // Otherwise use our internal preview - var url = DataTableCellUI.internalPreview.srchurl.replace("\${id}",id); + var url = DataTableCellUI.internalPreview.srchurl.replace("\${id}",encodeURIComponent(id)); $.ajax(url,{dataType:"jsonp"}).done(function(searchResponse) { var data = searchResponse.result[0]; var html = $.suggest.suggest.create_flyout(data, preview.imgurl);