diff --git a/client/src/utils/__tests__/svg.test.ts b/client/src/utils/__tests__/svg.test.ts
index 6d9b05f6bf..9b21fd1bdd 100644
--- a/client/src/utils/__tests__/svg.test.ts
+++ b/client/src/utils/__tests__/svg.test.ts
@@ -118,6 +118,24 @@ describe('isMonochromeSvg', () => {
'';
expect(isMonochromeSvg(svg)).toBe(true);
});
+
+ it('rejects a background rect using root width/height when no viewBox is present', () => {
+ const svg =
+ '';
+ expect(isMonochromeSvg(svg)).toBe(false);
+ });
+
+ it('rejects a background rect when root dimensions carry units', () => {
+ const svg =
+ '';
+ expect(isMonochromeSvg(svg)).toBe(false);
+ });
+
+ it('does not confuse stroke-width with the canvas width', () => {
+ const svg =
+ '';
+ expect(isMonochromeSvg(svg)).toBe(false);
+ });
});
});
diff --git a/client/src/utils/svg.ts b/client/src/utils/svg.ts
index 454c02da9b..01aad53a9e 100644
--- a/client/src/utils/svg.ts
+++ b/client/src/utils/svg.ts
@@ -104,13 +104,27 @@ function extractColors(svg: string): string[] {
}
const VIEWBOX_REGEX = /viewBox\s*=\s*["']\s*[-\d.]+\s+[-\d.]+\s+([\d.]+)\s+([\d.]+)/i;
+const SVG_TAG_REGEX = /