svg-ultralight 0.45.0__py3-none-any.whl → 0.45.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of svg-ultralight might be problematic. Click here for more details.

@@ -124,9 +124,23 @@ if TYPE_CHECKING:
124
124
  logging.getLogger("fontTools").setLevel(logging.ERROR)
125
125
 
126
126
 
127
+ _ESCAPE_CHARS = {"&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&apos;"}
128
+
129
+
130
+ def _sanitize_svg_data_text(text: str) -> str:
131
+ """Sanitize a string for use in an SVG data-text attribute.
132
+
133
+ :param text: The input string to sanitize.
134
+ :return: The sanitized string with XML characters escaped.
135
+ """
136
+ for char, escape_seq in _ESCAPE_CHARS.items():
137
+ text = text.replace(char, escape_seq)
138
+ return text
139
+
140
+
127
141
  # extract_gpos_kerning is an unfinished attempt to extract kerning from the GPOS
128
142
  # table.
129
- def get_gpos_kerning(font: TTFont) -> dict[tuple[str, str], int]:
143
+ def _get_gpos_kerning(font: TTFont) -> dict[tuple[str, str], int]:
130
144
  """Extract kerning pairs from the GPOS table of a font.
131
145
 
132
146
  :param font: A fontTools TTFont object.
@@ -325,7 +339,7 @@ class FTFontInfo:
325
339
  except (KeyError, AttributeError):
326
340
  kern = {}
327
341
  with suppress(Exception):
328
- kern.update(get_gpos_kerning(self.font))
342
+ kern.update(_get_gpos_kerning(self.font))
329
343
 
330
344
  return kern
331
345
 
@@ -532,7 +546,7 @@ class FTTextInfo:
532
546
  attributes["stroke-width"] = float(stroke_width) / self.scale
533
547
  return new_element(
534
548
  "path",
535
- data_text=self.text,
549
+ data_text=_sanitize_svg_data_text(self.text),
536
550
  d=self.font.get_text_svgd(self.text),
537
551
  **attributes,
538
552
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: svg-ultralight
3
- Version: 0.45.0
3
+ Version: 0.45.1
4
4
  Summary: a sensible way to create svg files with Python
5
5
  Author-email: Shay Hill <shay_public@hotmail.com>
6
6
  License: MIT
@@ -25,11 +25,11 @@ svg_ultralight/constructors/__init__.py,sha256=XLOInLhzMERWNnFAs-itMs-OZrBOpvQth
25
25
  svg_ultralight/constructors/new_element.py,sha256=kGRaVsT1yugADUCKz3NjFW_14Ts1M8UQeLPTarTXtBY,3529
26
26
  svg_ultralight/font_tools/__init__.py,sha256=NX3C0vvoB-G4S-h1f0NLWePjYAMMR37D1cl_G4WBjHc,83
27
27
  svg_ultralight/font_tools/comp_results.py,sha256=gFxdqY1D5z8MGt1UyWOK8O_t50AHgg-B846uWdzoLco,10687
28
- svg_ultralight/font_tools/font_info.py,sha256=UAOzz3-rsDl8TcbKh7baGcvwvTnpBJYuW71crjHUTE8,29400
28
+ svg_ultralight/font_tools/font_info.py,sha256=rIoEmEWhNYw04Jos_ETXQ11SkDhi6YlLd3VjZMLETXs,29875
29
29
  svg_ultralight/font_tools/globs.py,sha256=JdrrGMqDtD4WcY7YGUWV43DUW63RVev-x9vWqsQUhxU,119
30
30
  svg_ultralight/strings/__init__.py,sha256=BMGhF1pulscIgkiYvZLr6kPRR0L4lW0jUNFxkul4_EM,295
31
31
  svg_ultralight/strings/svg_strings.py,sha256=FQNxNmMkR2M-gCFo_woQKXLgCHi3ncUlRMiaRR_a9nQ,1978
32
- svg_ultralight-0.45.0.dist-info/METADATA,sha256=ywfQ4Rb8uBQRYmeGa88BZcoifcpwXcLip1pHMsOpXRc,9052
33
- svg_ultralight-0.45.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- svg_ultralight-0.45.0.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
35
- svg_ultralight-0.45.0.dist-info/RECORD,,
32
+ svg_ultralight-0.45.1.dist-info/METADATA,sha256=_5egao_AkYDDIGZ7iN4anNt2FzM9KeVuK_ZSUvI_UVs,9052
33
+ svg_ultralight-0.45.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ svg_ultralight-0.45.1.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
35
+ svg_ultralight-0.45.1.dist-info/RECORD,,