Skip to content

Commit 737a056

Browse files
authored
Merge pull request #944 from mapbox/as/fix-xss-vuln
Fix XSS Vulnerability & Sanitize with DOMPurify
2 parents 766d495 + 7cf170a commit 737a056

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"csv2geojson": "5.1.2",
3333
"d3": "3.5.17",
3434
"d3-metatable": "0.3.0",
35+
"dompurify": "^3.3.1",
3536
"escape-html": "^1.0.1",
3637
"file-saver": "2.0.5",
3738
"geojson-flatten": "^1.0.4",
@@ -86,7 +87,6 @@
8687
"test-browser": "browserify test/index.js | testling",
8788
"start": "concurrently --kill-others --names live-server rollup \"live-server --ignore=\"$PWD/src/**,$PWD/dist/**,$PWD/.git\"\" \"rollup -cw\" \"npx tailwindcss -i $PWD/src/css/tailwind_src.css -o $PWD/dist/css/tailwind_dist.css --watch\"",
8889
"build": "rimraf dist && npx tailwindcss -i ./src/css/tailwind_src.css -o ./dist/css/tailwind_dist.css && rollup -c",
89-
"build:next": "cd next && npm ci && npm run build",
9090
"serve": "cd dist && live-server"
9191
},
9292
"overrides": {

src/ui/map/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const mapboxgl = require('mapbox-gl');
22
const escape = require('escape-html');
33
const length = require('@turf/length').default;
44
const area = require('@turf/area').default;
5+
const DOMPurify = require('dompurify');
56

67
const popup = require('../../lib/popup');
78
const ClickableMarker = require('./clickable_marker');
@@ -113,7 +114,8 @@ const addMarkers = (geojson, context, writable) => {
113114
const color =
114115
(d.properties && d.properties['marker-color']) || defaultColor;
115116
const symbolColor =
116-
(d.properties && d.properties['symbol-color']) || defaultSymbolColor;
117+
(d.properties && DOMPurify.sanitize(d.properties['symbol-color'])) ||
118+
defaultSymbolColor;
117119

118120
let scale = 1;
119121
if (d.properties && d.properties['marker-size']) {

0 commit comments

Comments
 (0)