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