Merge pull request #276 from toeverything/bugfix/security-code-scanning

fix delete Regex
This commit is contained in:
Yifeng Wang 2022-08-17 17:13:26 +08:00 committed by GitHub
commit 7d459631e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3840,12 +3840,9 @@ export class TldrawApp extends StateManager<TDSnapshot> {
}; };
private get_viewbox_from_svg = (svgStr: string | ArrayBuffer | null) => { private get_viewbox_from_svg = (svgStr: string | ArrayBuffer | null) => {
const viewBoxRegex =
/.*?viewBox=["'](-?[\d.]+[, ]+-?[\d.]+[, ][\d.]+[, ][\d.]+)["']/;
if (typeof svgStr === 'string') { if (typeof svgStr === 'string') {
const matches = svgStr.match(viewBoxRegex); let viewBox = new DOMParser().parseFromString(svgStr, 'text/xml');
return matches && matches.length >= 2 ? matches[1] : null; return viewBox.children[0].getAttribute('viewBox');
} }
console.warn('could not get viewbox from svg string'); console.warn('could not get viewbox from svg string');