Skip to content

Commit

Permalink
Merge pull request #1225 from atmire/issue-1224-workflow-rejection-re…
Browse files Browse the repository at this point in the history
…ason-not-properly-encoded

Workflow rejection reasons are not properly encoded
  • Loading branch information
tdonohue authored Jun 17, 2021
2 parents cfd6512 + 586de36 commit e546a4f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/app/core/data/request.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,19 @@ describe('RequestService', () => {
});
});
});

describe('uriEncodeBody', () => {
it('should properly encode the body', () => {
const body = {
'property1': 'multiple\nlines\nto\nsend',
'property2': 'sp&ci@l characters',
'sp&ci@l-chars in prop': 'test123',
};
const queryParams = service.uriEncodeBody(body);
expect(queryParams).toEqual(
'property1=multiple%0Alines%0Ato%0Asend&property2=sp%26ci%40l%20characters&sp%26ci%40l-chars%20in%20prop=test123'
);
});
});

});
6 changes: 4 additions & 2 deletions src/app/core/data/request.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,13 @@ export class RequestService {
if (isNotEmpty(body) && typeof body === 'object') {
Object.keys(body)
.forEach((param) => {
const paramValue = `${param}=${body[param]}`;
const encodedParam = encodeURIComponent(param);
const encodedBody = encodeURIComponent(body[param]);
const paramValue = `${encodedParam}=${encodedBody}`;
queryParams = isEmpty(queryParams) ? queryParams.concat(paramValue) : queryParams.concat('&', paramValue);
});
}
return encodeURI(queryParams);
return queryParams;
}

/**
Expand Down

0 comments on commit e546a4f

Please sign in to comment.