(text)
| 84 | |
| 85 | |
| 86 | def _escape_cdata(text) -> str: |
| 87 | # escape character data |
| 88 | try: |
| 89 | # it's worth avoiding do-nothing calls for strings that are |
| 90 | # shorter than 500 character, or so. assume that's, by far, |
| 91 | # the most common case in most applications. |
| 92 | if "&" in text: |
| 93 | # Only replace & when not part of an entity |
| 94 | text = RE_AMP.sub('&', text) |
| 95 | if "<" in text: |
| 96 | text = text.replace("<", "<") |
| 97 | if ">" in text: |
| 98 | text = text.replace(">", ">") |
| 99 | return text |
| 100 | except (TypeError, AttributeError): # pragma: no cover |
| 101 | _raise_serialization_error(text) |
| 102 | |
| 103 | |
| 104 | def _escape_attrib(text: str) -> str: |
no test coverage detected