Return a control-character-free, HTML-escaped, bounded string.
(value: object)
| 472 | |
| 473 | |
| 474 | def _sanitize_metadata_string(value: object) -> str: |
| 475 | """Return a control-character-free, HTML-escaped, bounded string.""" |
| 476 | text = _CONTROL_CHAR_RE.sub("", str(value)) |
| 477 | text = html.escape(text, quote=True) |
| 478 | if len(text) > _METADATA_MAX_VALUE_LEN: |
| 479 | text = text[:_METADATA_MAX_VALUE_LEN] |
| 480 | return text # html is imported at module level (line 5) |
| 481 | |
| 482 | |
| 483 | def _sanitize_metadata_value(value: object) -> object: |
no outgoing calls