diff --git a/ui/javascripts/app/models.js b/ui/javascripts/app/models.js index 16a36a03b1..3cabf0ba8a 100644 --- a/ui/javascripts/app/models.js +++ b/ui/javascripts/app/models.js @@ -132,13 +132,20 @@ App.Key = Ember.Object.extend(Ember.Validations.Mixin, { // Boolean if the value is valid valueValid: Ember.computed.empty('errors.Value'), -// Escape any user-entered parts that aren't URL-safe, but put slashes back since -// they are common in keys, and the UI lets users make "folders" by simply adding -// them to keys. + // Escape any user-entered parts that aren't URL-safe, but put slashes back since + // they are common in keys, and the UI lets users make "folders" by simply adding + // them to keys. Key: function(key, value) { // setter if (arguments.length > 1) { - clean = encodeURIComponent(decodeURIComponent(value)).replace(/%2F/g, "/") + clean = value + try { + clean = decodeURIComponent(clean); + } catch (e) { + // If they've got something that's not valid URL syntax then keep going; + // this means that at worst we might end up double escaping some things. + } + clean = encodeURIComponent(clean).replace(/%2F/g, "/") this.set('cleanKey', clean); return clean; }