File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -144,16 +144,19 @@ export default class Icon extends Component {
144144 {
145145 'slds-icon' : ! / s l d s \- b u t t o n _ _ i c o n / . test ( className ) ,
146146 [ `slds-icon--${ size } ` ] : / ^ ( x - s m a l l | s m a l l | m e d i u m | l a r g e ) $ / . test ( size ) ,
147- [ `slds-icon-text-${ textColor } ` ] : / ^ ( d e f a u l t | w a r n i n g | e r r o r ) $ / . test ( textColor ) &&
148- ! iconColor ,
147+ [ `slds-icon-text-${ textColor } ` ] : / ^ ( d e f a u l t | w a r n i n g | e r r o r ) $ / . test ( textColor ) && ! iconColor ,
149148 [ `slds-icon-${ iconColor } ` ] : ! container && iconColor ,
150149 'slds-m-left--x-small' : align === 'right' ,
151150 'slds-m-right--x-small' : align === 'left' ,
152151 } ,
153152 className
154153 ) ;
155154
156- const useHtml = `${ getAssetRoot ( ) } /icons/${ category } -sprite/svg/symbols.svg#${ icon } ` ;
155+ // icon and category prop should not include chars other than alphanumerics, underscore, and hyphen
156+ icon = ( icon || '' ) . replace ( / [ ^ \w \- ] / g, '' ) ; // eslint-disable-line no-param-reassign
157+ category = ( category || '' ) . replace ( / [ ^ \w \- ] / g, '' ) ; // eslint-disable-line no-param-reassign
158+
159+ const iconUrl = `${ getAssetRoot ( ) } /icons/${ category } -sprite/svg/symbols.svg#${ icon } ` ;
157160 return (
158161 < svg
159162 className = { iconClassNames }
@@ -162,7 +165,7 @@ export default class Icon extends Component {
162165 style = { style }
163166 { ...props }
164167 >
165- < use xlinkHref = { useHtml } />
168+ < use xlinkHref = { iconUrl } />
166169 </ svg >
167170 ) ;
168171 }
You can’t perform that action at this time.
0 commit comments