From 42db4fccdfc868b1c5ecb677db20d7a6e37add33 Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Mon, 2 Jun 2014 20:05:27 +0400 Subject: [PATCH] Fix encoding issues for non-ASCII company names Change-Id: I466cccb5f24e78c791d7a060a1e0d06b9465e3c8 --- dashboard/static/js/stackalytics-ui.js | 16 ++++++++++++---- stackalytics/processor/utils.py | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dashboard/static/js/stackalytics-ui.js b/dashboard/static/js/stackalytics-ui.js index 0bd10f06d..54ccc1bc5 100644 --- a/dashboard/static/js/stackalytics-ui.js +++ b/dashboard/static/js/stackalytics-ui.js @@ -260,6 +260,12 @@ function extendWithGravatar(record, image_size) { }); } +function encodeURI(s) { + s = encodeURIComponent(s); + s = s.replace("*", "%2A"); + return s; +} + function getUrlVars() { var vars = {}; window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { @@ -270,7 +276,7 @@ function getUrlVars() { function makeLink(id, title, param_name) { var options = {}; - options[param_name] = encodeURIComponent(id).toLowerCase(); + options[param_name] = id.toLowerCase(); var link = makeURI("/", options); return "" + title + "" } @@ -282,7 +288,7 @@ function makeURI(uri, options) { $.extend(ops, options); } var str = $.map(ops,function (val, index) { - return index + "=" + encodeURIComponent(val).toLowerCase(); + return index + "=" + encodeURI(val).toLowerCase(); }).join("&"); return (str == "") ? uri : uri + "?" + str; @@ -301,7 +307,7 @@ function getPageState() { function reload(extra) { window.location.search = $.map($.extend(getUrlVars(), extra), function (val, index) { - return val? (index + "=" + encodeURIComponent(val)) : null; + return val? (index + "=" + val) : null; }).join("&") } @@ -322,7 +328,9 @@ function initSingleSelector(name, api_url, select2_extra_options, change_handler dataType: "jsonp", success: function (data) { var initial_value = getUrlVars()[name]; - if (!initial_value && data["default"]) { + if (initial_value) { + initial_value = encodeURI(initial_value); + } else if (data["default"]) { initial_value = data["default"]; } $(selectorId). diff --git a/stackalytics/processor/utils.py b/stackalytics/processor/utils.py index 56e2f45fb..302b78a24 100644 --- a/stackalytics/processor/utils.py +++ b/stackalytics/processor/utils.py @@ -189,7 +189,7 @@ def add_index(sequence, start=1, item_filter=lambda x: True): def safe_encode(s): - return parse.quote_plus(s.encode('utf-8')) + return parse.quote(s.encode('utf-8')) def make_module_group(module_group_id, name=None, modules=None, tag='module'):