Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates the web UI to escape invalid characters in keys. #3760

Merged
merged 4 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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