Sanitize input to handle potential encoding issues.
(text: str)
| 140 | return sanitized_html |
| 141 | |
| 142 | def sanitize_input_encode(text: str) -> str: |
| 143 | """Sanitize input to handle potential encoding issues.""" |
| 144 | try: |
| 145 | # Attempt to encode and decode as UTF-8 to handle potential encoding issues |
| 146 | return text.encode('utf-8', errors='ignore').decode('utf-8') |
| 147 | except UnicodeEncodeError as e: |
| 148 | print(f"Warning: Encoding issue detected. Some characters may be lost. Error: {e}") |
| 149 | # Fall back to ASCII if UTF-8 fails |
| 150 | return text.encode('ascii', errors='ignore').decode('ascii') |
| 151 | |
| 152 | def escape_json_string(s): |
| 153 | """ |
no outgoing calls
no test coverage detected
searching dependent graphs…