web: encodeURIComponent for zuul-manifest path

This change prevents the following errors when the zuul-manifest contains
percent:

  URIError: Pathname "..." could not be decoded.
  This is likely caused by an invalid percent-encoding.

Change-Id: I62dba8ddd6717c63d427017b03ff912e1fddcb0b
This commit is contained in:
Tristan Cacqueray 2024-06-10 15:50:31 +00:00
parent 4d296a5271
commit 8cf75cf5a5
2 changed files with 13 additions and 3 deletions

View File

@ -63,15 +63,15 @@ export const requestBuildOutput = () => ({
// job-output processing functions
export function renderTree(tenant, build, path, obj, textRenderer, defaultRenderer) {
const node = {}
let name = obj.name
let name = encodeURIComponent(obj.name)
if ('children' in obj && obj.children) {
node.nodes = obj.children.map(
n => renderTree(tenant, build, path+obj.name+'/', n,
n => renderTree(tenant, build, path+name+'/', n,
textRenderer, defaultRenderer))
}
if (obj.mimetype === 'application/directory') {
name = obj.name + '/'
name = name + '/'
} else {
node.icon = 'fa fa-file-o'
}

View File

@ -29,3 +29,13 @@ it('processes job-output properly', () => {
expect(tree).toEqual(
{'icon': 'fa fa-file-o', 'nodes': [], 'text': 'http://test'})
})
it('processes filename with % properly', () => {
let obj = {children: [], mimetype: 'test', name: 'test%el'}
let tree = buildAction.renderTree(
{linkPrefix: 'test/'},
{log_url: 'http://test/', uuid: 'test'},
'/', obj, (a) => (a), (_log_url, path, name) => (path + name))
expect(tree).toEqual(
{'icon': 'fa fa-file-o', 'nodes': [], 'text': '/test%25el'})
})