Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

fix: SVG metadata extraction regex on multiline elements (#5074)

Achille Lacoinb5a46dd67119
diff --git a/src/data/image.ts b/src/data/image.ts
index 912a708433..1c1a0a9277 100644
--- a/src/data/image.ts
+++ b/src/data/image.ts
@@ -105,7 +105,9 @@ export const encodeSvgMetadata = async ({ text }: { text: string }) => {
export const decodeSvgMetadata = async ({ svg }: { svg: string }) => {
if (svg.includes(`payload-type:${MIME_TYPES.excalidraw}`)) {
- const match = svg.match(/<!-- payload-start -->(.+?)<!-- payload-end -->/);
+ const match = svg.match(
+ /<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/,
+ );
if (!match) {
throw new Error("INVALID");
}