Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid direct assignment of innerHTML for Advanced Marker-based c… #744

Merged
merged 1 commit into from
Sep 11, 2023
Merged
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
8 changes: 5 additions & 3 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<circle cx="120" cy="120" opacity=".6" r="70" />
<circle cx="120" cy="120" opacity=".3" r="90" />
<circle cx="120" cy="120" opacity=".2" r="110" />
<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${count}</text>

Check warning

Code scanning / CodeQL

Unsafe HTML constructed from library input Medium

This HTML construction which depends on
library input
might later allow
cross-site scripting
.
</svg>`;

const title = `Cluster of ${count} markers`,
Expand All @@ -127,9 +127,11 @@

if (MarkerUtils.isAdvancedMarkerAvailable(map)) {
// create cluster SVG element
const div = document.createElement("div");
div.innerHTML = svg;
const svgEl = div.firstElementChild;
const parser = new DOMParser();
const svgEl = parser.parseFromString(
svg,
"image/svg+xml"
).documentElement;
svgEl.setAttribute("transform", "translate(0 25)");

const clusterOptions: google.maps.marker.AdvancedMarkerElementOptions = {
Expand Down
Loading