(text)
| 62 | |
| 63 | |
| 64 | def _escape_cdata(text) -> str: |
| 65 | # escape character data |
| 66 | try: |
| 67 | # it's worth avoiding do-nothing calls for strings that are |
| 68 | # shorter than 500 character, or so. assume that's, by far, |
| 69 | # the most common case in most applications. |
| 70 | if "&" in text: |
| 71 | # Only replace & when not part of an entity |
| 72 | text = RE_AMP.sub('&', text) |
| 73 | if "<" in text: |
| 74 | text = text.replace("<", "<") |
| 75 | if ">" in text: |
| 76 | text = text.replace(">", ">") |
| 77 | return text |
| 78 | except (TypeError, AttributeError): # pragma: no cover |
| 79 | _raise_serialization_error(text) |
| 80 | |
| 81 | |
| 82 | def _escape_attrib(text: str) -> str: |
no test coverage detected
searching dependent graphs…