| 2046 | |
| 2047 | |
| 2048 | def _escape_cdata_c14n(text): |
| 2049 | # escape character data |
| 2050 | try: |
| 2051 | # it's worth avoiding do-nothing calls for strings that are |
| 2052 | # shorter than 500 character, or so. assume that's, by far, |
| 2053 | # the most common case in most applications. |
| 2054 | if '&' in text: |
| 2055 | text = text.replace('&', '&') |
| 2056 | if '<' in text: |
| 2057 | text = text.replace('<', '<') |
| 2058 | if '>' in text: |
| 2059 | text = text.replace('>', '>') |
| 2060 | if '\r' in text: |
| 2061 | text = text.replace('\r', '
') |
| 2062 | return text |
| 2063 | except (TypeError, AttributeError): |
| 2064 | _raise_serialization_error(text) |
| 2065 | |
| 2066 | |
| 2067 | def _escape_attrib_c14n(text): |