Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ def main() -> int:
## Read untrusted_string from stdin if needed
if untrusted_string is None:
if sys.stdin is not None:
sys.stdin.reconfigure(errors="ignore") # type: ignore
sys.stdin.reconfigure( # type: ignore
encoding="utf-8", errors="replace", newline="\n"
)
untrusted_string = sys.stdin.read()
else:
## No way to get an untrusted string, print nothing and
## exit successfully
return 0

## Sanitize and print
sys.stdout.reconfigure( # type: ignore
encoding="ascii", errors="replace", newline="\n"
)
assert untrusted_string is not None
sanitized_string: str = sanitize_string(untrusted_string)
if max_string_length is not None:
Expand Down
Loading