From c74fce01803e0d2fc31cb078ec85786067cf35a6 Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Fri, 16 Oct 2015 15:21:21 -0400 Subject: [PATCH] Fix URL encoding - fixes #1059 Fixes both permalink & "browse this cluster". Substitutes encodeURIComponent for escape --- .../core/scripts/dialogs/clustering-dialog.js | 6 +++--- .../modules/core/scripts/index/open-project-ui.js | 2 +- main/webapp/modules/core/scripts/project.js | 8 +++----- .../core/scripts/reconciliation/recon-dialog.js | 2 +- main/webapp/modules/core/scripts/util/url.js | 14 +------------- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js index 785084c7e..dcb806094 100644 --- a/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/clustering-dialog.js @@ -196,13 +196,13 @@ ClusteringDialog.prototype._renderTable = function(clusters) { } var params = [ - "project=" + escape(theProject.id), - "ui=" + escape(JSON.stringify({ + "project=" + encodeURIComponent(theProject.id), + "ui=" + encodeURIComponent(JSON.stringify({ "facets" : [ facet ] })) ]; var url = "project?" + params.join("&"); - + var div = $('
').addClass("clustering-dialog-value-focus"); var browseLink = $(''+$.i18n._('core-dialogs')["browse-this-cluster"]+'') diff --git a/main/webapp/modules/core/scripts/index/open-project-ui.js b/main/webapp/modules/core/scripts/index/open-project-ui.js index 95334e805..2846d59df 100644 --- a/main/webapp/modules/core/scripts/index/open-project-ui.js +++ b/main/webapp/modules/core/scripts/index/open-project-ui.js @@ -229,7 +229,7 @@ Refine.OpenProjectUI.prototype._onClickUploadFileButton = function(evt) { } else { $("#file-upload-form").attr("action", "command/core/create-project-from-upload?" + [ - "url=" + escape(dataURL), + "url=" + encodeURICompnent(dataURL), "split-into-columns=" + $("#split-into-columns-input")[0].checked, "separator=" + $("#separator-input")[0].value, "ignore=" + $("#ignore-input")[0].value, diff --git a/main/webapp/modules/core/scripts/project.js b/main/webapp/modules/core/scripts/project.js index d83c61fb2..cf729f48f 100644 --- a/main/webapp/modules/core/scripts/project.js +++ b/main/webapp/modules/core/scripts/project.js @@ -62,8 +62,6 @@ Refine.reportException = function(e) { }; function resize() { - var header = $("#header"); - var leftPanelWidth = 300; var width = $(window).width(); var top = $("#header").outerHeight(); @@ -457,8 +455,8 @@ Refine.fetchRows = function(start, limit, onDone, sorting) { Refine.getPermanentLink = function() { var params = [ - "project=" + escape(theProject.id), - "ui=" + escape(JSON.stringify({ + "project=" + encodeURIComponent(theProject.id), + "ui=" + encodeURIComponent(JSON.stringify({ facets: ui.browsingEngine.getFacetUIStates() })) ]; @@ -475,7 +473,7 @@ function onLoad() { var uiState = {}; if ("ui" in params) { try { - uiState = JSON.parse(params.ui); + uiState = JSON.parse(decodeURIComponent(params.ui)); } catch (e) { } } diff --git a/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js b/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js index d3a8e8abb..56df3e1c2 100644 --- a/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js +++ b/main/webapp/modules/core/scripts/reconciliation/recon-dialog.js @@ -257,7 +257,7 @@ ReconDialog.prototype._onAddNamespacedService = function() { var typeData = elmts.typeInput.data("data.suggest"); if (namespaceData) { var url = "http://reconcile.freebaseapps.com/namespace_reconcile?namespace=" - + escape(namespaceData.id); + + encodeURIComponent(namespaceData.id); if (typeData) { url += "&type=" + typeData.id; } diff --git a/main/webapp/modules/core/scripts/util/url.js b/main/webapp/modules/core/scripts/util/url.js index 998fe849c..93168cee9 100644 --- a/main/webapp/modules/core/scripts/util/url.js +++ b/main/webapp/modules/core/scripts/util/url.js @@ -82,7 +82,7 @@ URL.getParameters = function() { params = params.substr(1).split("&"); $.each(params, function() { pair = this.split("="); - r[pair[0]] = unescape(pair[1]); + r[pair[0]] = decodeURIComponent(pair[1]); }); } @@ -102,15 +102,3 @@ URL.looksLikeUrl = function(s) { return false; }; -URL.getHostname = function(){ - var url = location.href; // entire url including querystring - also: window.location.href; - var baseURL = url.substring(0, url.indexOf('/',7));//7 is the length of http:// - return baseURL; -}; - -URL.urlify = function(str) { - if(!str) { - return ''; - } - return escape(str.replace(/\W/g, '_')); -}; \ No newline at end of file