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:
parent
122811d768
commit
dbaf98412f
1 changed files with 1 additions and 1 deletions
|
@ -18,7 +18,7 @@ class CardMedia extends React.PureComponent<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = thumbnail || Placeholder;
|
const url = thumbnail || Placeholder;
|
||||||
return <div style={{ backgroundImage: `url('${url}')` }} className={className} />;
|
return <div style={{ backgroundImage: `url('${url.replace(/'/g,"\\'")}')` }} className={className} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue