Sanitize urls with single quotation marks

This fixes behavior for URLs with single quotes within them.
The behavior for a url like `https://severalglamorousthing.426729.repl.co/google's%20logo.png` would be no background at all; the CSS rule would change to `background-image: url((unknown));`.
This fixes the problem and adds `\` to every `'` in the image url.
The behavior of the repo with this fix would be a conversion of the url provided above to  `https://severalglamorousthing.426729.repl.co/google\'s%20logo.png`, which can be put into `\`url('${url}')\`` without breaking the CSS rule.
This commit is contained in:
Sesamestrong 2019-10-20 19:24:55 -04:00 committed by Sean Yesmunt
parent 122811d768
commit dbaf98412f

View file

@ -18,7 +18,7 @@ class CardMedia extends React.PureComponent<Props> {
}
const url = thumbnail || Placeholder;
return <div style={{ backgroundImage: `url('${url}')` }} className={className} />;
return <div style={{ backgroundImage: `url('${url.replace(/'/g,"\\'")}')` }} className={className} />;
}
}