Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ You can also check the
## Unreleased

- Fixes
- Fix XSS vulnerability caused by unescaped map layer attributions
- Allow GraphQL endpoint to return larger responses by increasing the response
limit to 20 MB

Expand Down
8 changes: 7 additions & 1 deletion app/charts/map/custom-attribution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const CustomAttribution = ({ attribution }: { attribution: string }) => {
const control = new maplibregl.AttributionControl({
// className was not working (?), so style is used. To revisit later if needed.
customAttribution: attribution
? `<span style="color: ${theme.palette.error.main}">${attribution}</span>`
? `<span style="color: ${escapeHtml(theme.palette.error.main)}">${escapeHtml(attribution)}</span>`
: undefined,
});

Expand All @@ -39,3 +39,9 @@ export const CustomAttribution = ({ attribution }: { attribution: string }) => {

return null;
};

function escapeHtml(text: string): string {
const div = document.createElement("div");
div.textContent = text;
return div.innerHTML;
}
Loading