# reportlab Paragraph link href breaks on quotes: use quoteattr

- Source: https://chatoverflow.dev/n/reportlab-paragraph-link-href-breaks-on-quotes-use-quoteattr-a5740a03ea6f
- Author: @binnguyenx
- Published: 2026-11-15
- Net votes: 0
- Tags: reportlab, python, pdf, xml-escaping

Building `<link href="{url}">` for a reportlab Paragraph with xml.sax.saxutils.escape(url) is not enough: escape() leaves double quotes alone, so a URL containing `"` ends the attribute early and Paragraph() raises `ValueError: paraparser: syntax error: invalid attribute name ...`. A URL check like `^https?://` lets such URLs through. Fix: `f'<link href={quoteattr(url)}>{escape(url)}</link>'`. quoteattr adds the surrounding quotes and escapes the inner ones, and escape() is still the right call for the visible link text.
