Skip to content

Commit

Permalink
Encoding fields in HTTP headers (#523)
Browse files Browse the repository at this point in the history
* Encoding fields to make sure we don't send UTF8 inside the HTTP header

* Updating reference to use æøå (which is not allowed in JsonSchema, but the app should now crash with this component ID either)

Co-authored-by: Ole Martin Handeland <[email protected]>
  • Loading branch information
olemartinorg and Ole Martin Handeland authored Oct 7, 2022
1 parent c6f407c commit 1d0c6ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ describe('submitFormDataSagas', () => {
[
call(put, dataElementUrl(defaultDataElementGuid), model, {
headers: {
'X-DataField': field,
'X-ComponentId': componentId,
'X-DataField': encodeURIComponent(field),
'X-ComponentId': encodeURIComponent(componentId),
},
}),
{},
Expand Down Expand Up @@ -167,8 +167,8 @@ describe('submitFormDataSagas', () => {
{
headers: {
party: `partyid:${stateMock.party.selectedParty.partyId}`,
'X-DataField': field,
'X-ComponentId': componentId,
'X-DataField': encodeURIComponent(field),
'X-ComponentId': encodeURIComponent(componentId),
},
},
model,
Expand Down Expand Up @@ -257,8 +257,8 @@ describe('submitFormDataSagas', () => {
getStatelessFormDataUrl(currentDataType, true),
{
headers: {
'X-DataField': field,
'X-ComponentId': componentId,
'X-DataField': encodeURIComponent(field),
'X-ComponentId': encodeURIComponent(componentId),
},
},
model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export function* putFormData({
try {
const options: AxiosRequestConfig = {
headers: {
'X-DataField': field,
'X-ComponentId': componentId,
'X-DataField': encodeURIComponent(field),
'X-ComponentId': encodeURIComponent(componentId),
},
};
yield call(put, dataElementUrl(defaultDataElementGuid), model, options);
Expand Down Expand Up @@ -224,8 +224,8 @@ export function* saveStatelessData({
const allowAnonymous = yield select(makeGetAllowAnonymousSelector());
let options: AxiosRequestConfig = {
headers: {
'X-DataField': field,
'X-ComponentId': componentId,
'X-DataField': encodeURIComponent(field),
'X-ComponentId': encodeURIComponent(componentId),
},
};
if (!allowAnonymous) {
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/pageobjects/app-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class AppFrontend {
newMiddleName: '#newMiddleName',
newMiddleNameDescription: '#description-newMiddleName',
oldFullName: '#changeNameFrom',
newFullName: '#changeNameTo',
newFullName: '#changeNameTo_æøå',
confirmChangeName: '#confirmChangeName',
reasons: '#reason',
reference: '#reference',
Expand Down

0 comments on commit 1d0c6ce

Please sign in to comment.