Skip to content

Commit

Permalink
Merge pull request #3760 from hashicorp/ui-updates
Browse files Browse the repository at this point in the history
Updates the web UI to escape invalid characters in keys.
  • Loading branch information
slackpad authored Dec 20, 2017
2 parents ec423f1 + 2dfa9e3 commit a404f36
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ IMPROVEMENTS:

BUG FIXES:

* ui: Added a URI escape around key/value keys so that it's not possible to create unexpected partial key names when entering characters like `?` inside a key. [GH-3760]

## 1.0.2 (December 15, 2017)

IMPROVEMENTS:
Expand Down
64 changes: 32 additions & 32 deletions agent/bindata_assetfs.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion agent/consul/server_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func init() {
registerEndpoint(func(s *Server) interface{} { return &Session{s} })
registerEndpoint(func(s *Server) interface{} { return &Status{s} })
registerEndpoint(func(s *Server) interface{} { return &Txn{s} })
}
}
15 changes: 15 additions & 0 deletions ui/javascripts/app/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ 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.
Key: function(key, value) {
// setter
if (arguments.length > 1) {
clean = encodeURIComponent(decodeURIComponent(value)).replace(/%2F/g, "/")
this.set('cleanKey', clean);
return clean;
}

// getter
return this.get('cleanKey')
}.property('Key'),

// The key with the parent removed.
// This is only for display purposes, and used for
// showing the key name inside of a nested key.
Expand Down

0 comments on commit a404f36

Please sign in to comment.