File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,11 @@ export default class Icon extends Component {
153153 className
154154 ) ;
155155
156- const useHtml = `${ getAssetRoot ( ) } /icons/${ category } -sprite/svg/symbols.svg#${ icon } ` ;
156+ // icon and category prop should not include chars other than alphanumerics, underscore, and hyphen
157+ icon = ( icon || '' ) . replace ( / [ ^ \w \- ] / g, '' ) ; // eslint-disable-line no-param-reassign
158+ category = ( category || '' ) . replace ( / [ ^ \w \- ] / g, '' ) ; // eslint-disable-line no-param-reassign
159+
160+ const iconUrl = `${ getAssetRoot ( ) } /icons/${ category } -sprite/svg/symbols.svg#${ icon } ` ;
157161 return (
158162 < svg
159163 className = { iconClassNames }
@@ -162,7 +166,7 @@ export default class Icon extends Component {
162166 style = { style }
163167 { ...props }
164168 >
165- < use xlinkHref = { useHtml } />
169+ < use xlinkHref = { iconUrl } />
166170 </ svg >
167171 ) ;
168172 }
You can’t perform that action at this time.
0 commit comments