diff --git a/CHANGES.rst b/CHANGES.rst index 262b84af..e1edd431 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -38,9 +38,10 @@ WIP - **Added** ``GappedCircleModuleDrawer`` (PIL) to render QR code modules as non-contiguous circles. (BenwestGate in `#373`_) - **Added** ability to execute as a Python module: ``python -m qrcode --output qrcode.png "hello world"`` (stefansjs in `#400`_) - **Removed** the hardcoded 'id' argument from SVG elements. The fixed element ID caused conflicts when embedding multiple QR codes in a single document. (m000 in `#385`_) -- Improved test coveraged (akx in `#315`_) -- Fixed typos in code that used ``embeded`` instead of ``embedded``. For backwards compatibility, the misspelled parameter names are still accepted but now emit deprecation warnings. These deprecated parameter names will be removed in v9.0. (benjnicholls in `#349`_) +- **Fixed** typos in code that used ``embeded`` instead of ``embedded``. For backwards compatibility, the misspelled parameter names are still accepted but now emit deprecation warnings. These deprecated parameter names will be removed in v9.0. (benjnicholls in `#349`_) +- **Fixed** an issue where an `` None: super().initialize(*args, **kwargs) - self.tag_qname = ET.QName(self.img._SVG_namespace, self.tag) def drawrect(self, box, is_active: bool): if not is_active: @@ -72,7 +71,7 @@ def initialize(self, *args, **kwargs) -> None: def el(self, box): coords = self.coords(box) return ET.Element( - self.tag_qname, + self.tag, x=self.img.units(coords.x0), y=self.img.units(coords.y0), width=self.unit_size, @@ -90,7 +89,7 @@ def initialize(self, *args, **kwargs) -> None: def el(self, box): coords = self.coords(box) return ET.Element( - self.tag_qname, + self.tag, cx=self.img.units(coords.xh), cy=self.img.units(coords.yh), r=self.radius, diff --git a/qrcode/tests/regression/__init__.py b/qrcode/tests/regression/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/qrcode/tests/regression/test_svg_rect.py b/qrcode/tests/regression/test_svg_rect.py new file mode 100644 index 00000000..77eda094 --- /dev/null +++ b/qrcode/tests/regression/test_svg_rect.py @@ -0,0 +1,44 @@ +import io + +import pytest + +import qrcode +from qrcode.image import svg +from qrcode.tests.consts import UNICODE_TEXT + + +@pytest.mark.parametrize( + "image_factory", + [ + svg.SvgFillImage, + svg.SvgFragmentImage, + svg.SvgImage, + svg.SvgPathFillImage, + # svg.SvgPathImage, # Result does not contain elements. + + This regression test ensures that rect elements in SVG output are rendered as + without the svg: namespace prefix, which can cause rendering issues in + browsers, when loaded in HTML. + + https://github.com/lincolnloop/python-qrcode/issues/353 + https://github.com/lincolnloop/python-qrcode/issues/317 + """ + # Create a QR code + qr = qrcode.QRCode() + qr.add_data(UNICODE_TEXT) + + img = qr.make_image(image_factory=image_factory) + f = io.BytesIO() + img.save(f) + svg_content = f.getvalue().decode("utf-8") + + # Check that there are no elements in the output + assert " elements in the output + assert "