-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
UI - fix encoding for user-entered paths #6294
Changes from all commits
405484d
3f4120e
42f0bcd
0dfd63f
f50ef8a
bd063f7
e852029
87fdc11
21d032b
8044d0e
b14249b
21f4f71
9ede572
5d08564
c4af1b7
774eaf2
3aaa45b
f5f6605
9e97244
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ import { isEmpty } from '@ember/utils'; | |
import { get } from '@ember/object'; | ||
import ApplicationAdapter from './application'; | ||
import DS from 'ember-data'; | ||
import { encodePath } from 'vault/utils/path-encoding-helpers'; | ||
|
||
export default ApplicationAdapter.extend({ | ||
namespace: 'v1', | ||
_url(backend, id, infix = 'data') { | ||
let url = `${this.buildURL()}/${backend}/${infix}/`; | ||
let url = `${this.buildURL()}/${encodePath(backend)}/${infix}/`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah this was the other possibly user generated value here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it's hardcoded - it'll either be |
||
if (!isEmpty(id)) { | ||
url = url + id; | ||
url = url + encodePath(id); | ||
} | ||
return url; | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import ApplicationAdapter from './application'; | ||
import { pluralize } from 'ember-inflector'; | ||
import { encodePath } from 'vault/utils/path-encoding-helpers'; | ||
|
||
export default ApplicationAdapter.extend({ | ||
namespace: 'v1', | ||
|
@@ -47,29 +48,29 @@ export default ApplicationAdapter.extend({ | |
}, | ||
|
||
urlForSecret(backend, id) { | ||
let url = `${this.buildURL()}/${backend}/keys/`; | ||
let url = `${this.buildURL()}/${encodePath(backend)}/keys/`; | ||
if (id) { | ||
url += id; | ||
url += encodePath(id); | ||
} | ||
return url; | ||
}, | ||
|
||
urlForAction(action, backend, id, param) { | ||
let urlBase = `${this.buildURL()}/${backend}/${action}`; | ||
let urlBase = `${this.buildURL()}/${encodePath(backend)}/${action}`; | ||
// these aren't key-specific | ||
if (action === 'hash' || action === 'random') { | ||
return urlBase; | ||
} | ||
if (action === 'datakey' && param) { | ||
// datakey action has `wrapped` or `plaintext` as part of the url | ||
return `${urlBase}/${param}/${id}`; | ||
return `${urlBase}/${param}/${encodePath(id)}`; | ||
} | ||
if (action === 'export' && param) { | ||
let [type, version] = param; | ||
const exportBase = `${urlBase}/${type}-key/${id}`; | ||
const exportBase = `${urlBase}/${type}-key/${encodePath(id)}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sure you've checked these but just a triple sanity check that Actually, just spotted something, 1 question around a slightly different thing here. You treat Sorry 1 more tiny teeny nit. I'm not sure what your There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, the type and action are hard-coded elsewhere in the app, the only thing the user does is name the transit key (which is the id). Good spot on the array vs string, I'll follow up on that! Re: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, found the |
||
return version ? `${exportBase}/${version}` : exportBase; | ||
} | ||
return `${urlBase}/${id}`; | ||
return `${urlBase}/${encodePath(id)}`; | ||
}, | ||
|
||
optionsForQuery(id) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again just a sanity check that this doesn't need encoding here, you encode it on 49 but not on 50
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we're only encoding when it goes to the server via ajax, and when it goes to the URL for routing - here it's going to be put in ember data for the model so we want the decoded version for display.