diff --git a/client/src/utils/__tests__/svg.test.ts b/client/src/utils/__tests__/svg.test.ts index 9b21fd1bdd..2d7c01f8ba 100644 --- a/client/src/utils/__tests__/svg.test.ts +++ b/client/src/utils/__tests__/svg.test.ts @@ -136,6 +136,12 @@ describe('isMonochromeSvg', () => { ''; expect(isMonochromeSvg(svg)).toBe(false); }); + + it('rejects a background rect when the viewBox is comma-separated', () => { + const svg = + ''; + expect(isMonochromeSvg(svg)).toBe(false); + }); }); }); diff --git a/client/src/utils/svg.ts b/client/src/utils/svg.ts index 01aad53a9e..9989af6f5e 100644 --- a/client/src/utils/svg.ts +++ b/client/src/utils/svg.ts @@ -103,7 +103,7 @@ function extractColors(svg: string): string[] { return colors; } -const VIEWBOX_REGEX = /viewBox\s*=\s*["']\s*[-\d.]+\s+[-\d.]+\s+([\d.]+)\s+([\d.]+)/i; +const VIEWBOX_REGEX = /viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)/i; const SVG_TAG_REGEX = /]*>/i; const RECT_REGEX = /]*>/gi;