(text: str)
| 102 | |
| 103 | |
| 104 | def _escape_attrib(text: str) -> str: |
| 105 | # escape attribute value |
| 106 | try: |
| 107 | if "&" in text: |
| 108 | # Only replace & when not part of an entity |
| 109 | text = RE_AMP.sub('&', text) |
| 110 | if "<" in text: |
| 111 | text = text.replace("<", "<") |
| 112 | if ">" in text: |
| 113 | text = text.replace(">", ">") |
| 114 | if "\"" in text: |
| 115 | text = text.replace("\"", """) |
| 116 | if "\n" in text: |
| 117 | text = text.replace("\n", " ") |
| 118 | return text |
| 119 | except (TypeError, AttributeError): # pragma: no cover |
| 120 | _raise_serialization_error(text) |
| 121 | |
| 122 | |
| 123 | def _escape_attrib_html(text: str) -> str: |
no test coverage detected