(text)
| 1032 | _raise_serialization_error(text) |
| 1033 | |
| 1034 | def _escape_attrib(text): |
| 1035 | # escape attribute value |
| 1036 | try: |
| 1037 | if "&" in text: |
| 1038 | text = text.replace("&", "&") |
| 1039 | if "<" in text: |
| 1040 | text = text.replace("<", "<") |
| 1041 | if ">" in text: |
| 1042 | text = text.replace(">", ">") |
| 1043 | if "\"" in text: |
| 1044 | text = text.replace("\"", """) |
| 1045 | # Although section 2.11 of the XML specification states that CR or |
| 1046 | # CR LN should be replaced with just LN, it applies only to EOLNs |
| 1047 | # which take part of organizing file into lines. Within attributes, |
| 1048 | # we are replacing these with entity numbers, so they do not count. |
| 1049 | # http://www.w3.org/TR/REC-xml/#sec-line-ends |
| 1050 | # The current solution, contained in following six lines, was |
| 1051 | # discussed in issue 17582 and 39011. |
| 1052 | if "\r" in text: |
| 1053 | text = text.replace("\r", " ") |
| 1054 | if "\n" in text: |
| 1055 | text = text.replace("\n", " ") |
| 1056 | if "\t" in text: |
| 1057 | text = text.replace("\t", "	") |
| 1058 | return text |
| 1059 | except (TypeError, AttributeError): |
| 1060 | _raise_serialization_error(text) |
| 1061 | |
| 1062 | def _escape_attrib_html(text): |
| 1063 | # escape attribute value |
no test coverage detected
searching dependent graphs…