(text: str)
| 80 | |
| 81 | |
| 82 | def _escape_attrib(text: str) -> str: |
| 83 | # escape attribute value |
| 84 | try: |
| 85 | if "&" in text: |
| 86 | # Only replace & when not part of an entity |
| 87 | text = RE_AMP.sub('&', text) |
| 88 | if "<" in text: |
| 89 | text = text.replace("<", "<") |
| 90 | if ">" in text: |
| 91 | text = text.replace(">", ">") |
| 92 | if "\"" in text: |
| 93 | text = text.replace("\"", """) |
| 94 | if "\n" in text: |
| 95 | text = text.replace("\n", " ") |
| 96 | return text |
| 97 | except (TypeError, AttributeError): # pragma: no cover |
| 98 | _raise_serialization_error(text) |
| 99 | |
| 100 | |
| 101 | def _escape_attrib_html(text: str) -> str: |
no test coverage detected