mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 01:32:56 +03:00
Merge pull request #276 from toeverything/bugfix/security-code-scanning
fix delete Regex
This commit is contained in:
commit
7d459631e6
@ -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');
|
||||||
|
Loading…
Reference in New Issue
Block a user