Fix URL encoding - fixes #1059

Fixes both permalink & "browse this cluster".
Substitutes encodeURIComponent for escape
This commit is contained in:
Tom Morris 2015-10-16 15:21:21 -04:00
parent 4834deca5e
commit c74fce0180
5 changed files with 9 additions and 23 deletions

View File

@ -196,13 +196,13 @@ ClusteringDialog.prototype._renderTable = function(clusters) {
} }
var params = [ var params = [
"project=" + escape(theProject.id), "project=" + encodeURIComponent(theProject.id),
"ui=" + escape(JSON.stringify({ "ui=" + encodeURIComponent(JSON.stringify({
"facets" : [ facet ] "facets" : [ facet ]
})) }))
]; ];
var url = "project?" + params.join("&"); var url = "project?" + params.join("&");
var div = $('<div></div>').addClass("clustering-dialog-value-focus"); var div = $('<div></div>').addClass("clustering-dialog-value-focus");
var browseLink = $('<a target="_new" title="'+$.i18n._('core-dialogs')["browse-only-these"]+'">'+$.i18n._('core-dialogs')["browse-this-cluster"]+'</a>') var browseLink = $('<a target="_new" title="'+$.i18n._('core-dialogs')["browse-only-these"]+'">'+$.i18n._('core-dialogs')["browse-this-cluster"]+'</a>')

View File

@ -229,7 +229,7 @@ Refine.OpenProjectUI.prototype._onClickUploadFileButton = function(evt) {
} else { } else {
$("#file-upload-form").attr("action", $("#file-upload-form").attr("action",
"command/core/create-project-from-upload?" + [ "command/core/create-project-from-upload?" + [
"url=" + escape(dataURL), "url=" + encodeURICompnent(dataURL),
"split-into-columns=" + $("#split-into-columns-input")[0].checked, "split-into-columns=" + $("#split-into-columns-input")[0].checked,
"separator=" + $("#separator-input")[0].value, "separator=" + $("#separator-input")[0].value,
"ignore=" + $("#ignore-input")[0].value, "ignore=" + $("#ignore-input")[0].value,

View File

@ -62,8 +62,6 @@ Refine.reportException = function(e) {
}; };
function resize() { function resize() {
var header = $("#header");
var leftPanelWidth = 300; var leftPanelWidth = 300;
var width = $(window).width(); var width = $(window).width();
var top = $("#header").outerHeight(); var top = $("#header").outerHeight();
@ -457,8 +455,8 @@ Refine.fetchRows = function(start, limit, onDone, sorting) {
Refine.getPermanentLink = function() { Refine.getPermanentLink = function() {
var params = [ var params = [
"project=" + escape(theProject.id), "project=" + encodeURIComponent(theProject.id),
"ui=" + escape(JSON.stringify({ "ui=" + encodeURIComponent(JSON.stringify({
facets: ui.browsingEngine.getFacetUIStates() facets: ui.browsingEngine.getFacetUIStates()
})) }))
]; ];
@ -475,7 +473,7 @@ function onLoad() {
var uiState = {}; var uiState = {};
if ("ui" in params) { if ("ui" in params) {
try { try {
uiState = JSON.parse(params.ui); uiState = JSON.parse(decodeURIComponent(params.ui));
} catch (e) { } catch (e) {
} }
} }

View File

@ -257,7 +257,7 @@ ReconDialog.prototype._onAddNamespacedService = function() {
var typeData = elmts.typeInput.data("data.suggest"); var typeData = elmts.typeInput.data("data.suggest");
if (namespaceData) { if (namespaceData) {
var url = "http://reconcile.freebaseapps.com/namespace_reconcile?namespace=" var url = "http://reconcile.freebaseapps.com/namespace_reconcile?namespace="
+ escape(namespaceData.id); + encodeURIComponent(namespaceData.id);
if (typeData) { if (typeData) {
url += "&type=" + typeData.id; url += "&type=" + typeData.id;
} }

View File

@ -82,7 +82,7 @@ URL.getParameters = function() {
params = params.substr(1).split("&"); params = params.substr(1).split("&");
$.each(params, function() { $.each(params, function() {
pair = this.split("="); 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; 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, '_'));
};