Skip to content

Commit

Permalink
Merge pull request #1209 from ivan-aksamentov/fix/unescaped-css-selec…
Browse files Browse the repository at this point in the history
…tors

fix: ensure generated svg ids are escaped
  • Loading branch information
jameshadfield authored Sep 18, 2020
2 parents 468a34e + 2a962c8 commit 99acab5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"core-js": "^3.6.5",
"create-react-class": "^15.6.0",
"css-loader": "^2.1.1",
"css.escape": "^1.5.1",
"d3-array": "^1.2.0",
"d3-axis": "^1.0.6",
"d3-brush": "^1.0.4",
Expand Down
5 changes: 3 additions & 2 deletions src/components/tree/phyloTree/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import {getTraitFromNode, getDivFromNode} from "../../../util/treeMiscHelpers";
* Note that this cannot have any "special" characters
*/
export const getDomId = (type, strain) => {
const name = typeof strain === "string" ? strain.replace(/[/_.;,~|[\]-]/g, '') : strain;
return `${type}_${name}`;
// Replace non-alphanumeric characters with dashes (probably unnecessary)
const name = `${type}_${strain}`.replace(/(\W+)/g, '-');
return CSS.escape(name);
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import "whatwg-fetch"; // eslint-disable-line
import "core-js";
import "regenerator-runtime";
import "css.escape";
/* L I B R A R I E S */
import "react-hot-loader";
import React from "react";
Expand Down

0 comments on commit 99acab5

Please sign in to comment.