Skip to content
Closed
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
22 changes: 21 additions & 1 deletion src/frontend/wwwroot/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,31 @@

const fetchTasksIfNeeded = async () => {
const taskStore = JSON.parse(sessionStorage.getItem('task'));

const sanitizeHeaderValue = (value) => {
// Ensure the value is a valid UTF-8 string and URL-encode non-ASCII characters
return encodeURIComponent(value);
};

const sanitizeHeaders = (headers) => {
const sanitizedHeaders = {};
for (const key in headers) {
if (headers.hasOwnProperty(key)) {
const sanitizedKey = sanitizeHeaderValue(key); // Sanitize the key
const sanitizedValue = sanitizeHeaderValue(headers[key]); // Sanitize the value
sanitizedHeaders[sanitizedKey] = sanitizedValue;
}
}
return sanitizedHeaders;
};

window.headers
.then(headers => {
const sanitized = sanitizeHeaders(headers);
console.log("Sanitized Headers:", sanitized);
fetch(apiEndpoint + '/plans', {
method: 'GET',
headers: headers,
headers: sanitized,
})
.then(response => response.json())
.then(data => {
Expand Down
Loading