The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
code improvements
Pedro Ladeira4a8f1bdc56e0
diff --git a/apps/web/lib/qr/api.tsx b/apps/web/lib/qr/api.tsxindex 04f60c4741..0a17fb941e 100644--- a/apps/web/lib/qr/api.tsx+++ b/apps/web/lib/qr/api.tsx@@ -71,15 +71,22 @@ export async function getQRAsSVG(props: QRPropsSVG): Promise<string> {// Drawing strategy: instead of a rect per module, we're going to create a// single path for the dark modules. Background is only painted when bgColor// is set — otherwise the SVG stays transparent.+ const escapeSvgAttr = (value: string) =>+ value+ .replace(/&/g, "&")+ .replace(/"/g, """)+ .replace(/</g, "<")+ .replace(/>/g, ">");+const fgPath = generatePath(cells, margin);const bgPath = bgColor- ? `<path fill="${bgColor}" d="M0,0 h${numCells}v${numCells}H0z" shape-rendering="crispEdges"></path>`+ ? `<path fill="${escapeSvgAttr(bgColor)}" d="M0,0 h${numCells}v${numCells}H0z" shape-rendering="crispEdges"></path>`: "";return [`<svg xmlns="http://www.w3.org/2000/svg" height="${size}" width="${size}" viewBox="0 0 ${numCells} ${numCells}">`,bgPath,- `<path fill="${fgColor}" d="${fgPath}" shape-rendering="crispEdges"></path>`,+ `<path fill="${escapeSvgAttr(fgColor)}" d="${fgPath}" shape-rendering="crispEdges"></path>`,image,"</svg>",].join("");