Skip to content

Commit 54b74cd

Browse files
committed
Merge remote-tracking branch 'ArrayBolt3/arraybolt3/trixie'
2 parents df92172 + 47c6252 commit 54b74cd

6 files changed

Lines changed: 17 additions & 21 deletions

File tree

run-tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ done
3131
stdin_file_read_utils=(stcat stcatn)
3232
stdin_implicit_read_utils=(sttee stsponge strip-markup unicode-show)
3333
stdin_utils=("${stdin_file_read_utils[@]}" "${stdin_implicit_read_utils[@]}")
34-
utils=(stprint stecho "${stdin_utils[@]}")
34+
utils=(stprint stecho sanitize-string "${stdin_utils[@]}")
3535
cd "${git_toplevel}/usr/bin"
3636
"${black[@]}" -- "${utils[@]}"
3737
"${pylint[@]}" -- "${utils[@]}"

unicode-testscript

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,23 @@ process_file() {
5858
fi
5959

6060
if cat -- "$file_name" | unicode-show >/dev/null ; then
61-
## unicode-show exit code non-zero.
61+
## unicode-show exit code 0.
6262
printf "%s\n" "$0: ERROR: Failed to find unicode using 'unicode-show' (stdin check) in file '$file_name'." >&2
6363
exit 1
6464
fi
65-
## unicode-show exit code 0.
65+
## unicode-show exit code non-zero.
6666

6767
## 'stcatn' should sanitize. Therefore 'unicode-show' should not find any unicode and exit 0.
6868
## Check if there is a non-zero exit code in this pipe, because if so, that's a bug.
6969
if ! stcatn "$file_name" | unicode-show >/dev/null ; then
70-
## unicode-show exit code 0.
70+
## unicode-show exit code non-zero.
7171
printf "%s\n" "$0: ERROR: Failed to sanitize string using 'stcatn' in file '$file_name'." >&2
7272
exit 1
7373
fi
74-
## unicode-show non-zero exit code.
74+
## unicode-show exit code 0.
7575

7676
if ! cat -- "$file_name" | sanitize-string nolimit >/dev/null ; then
77-
## unicode-show exit code 0.
77+
## sanitize-string exit code non-zero.
7878
printf "%s\n" "$0: ERROR: Failed to sanitize string using 'sanitize-string' (stdin check) in file '$file_name'." >&2
7979
exit 1
8080
fi
@@ -83,7 +83,7 @@ process_file() {
8383
file_content="$(cat -- "$file_name")"
8484

8585
if ! sanitize-string nolimit "$file_content" >/dev/null ; then
86-
## unicode-show exit code 0.
86+
## sanitize-string exit code non-zero.
8787
printf "%s\n" "$0: ERROR: Failed to sanitize string using 'sanitize-string' (command check) in file '$file_name'." >&2
8888
exit 1
8989
fi
@@ -97,6 +97,7 @@ $0: ERROR: Folder '$HOME/trojan-source' missing. To get it:
9797
9898
cd ~
9999
git clone git@github.com:nickboucher/trojan-source.git" >&2
100+
exit 1
100101
fi
101102

102103
## Creates files:

usr/bin/grep-find-unicode-wrapper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ check_grep_status() {
1616
elif [ "$1" = "1" ]; then
1717
true "$0: INFO: No match."
1818
else
19-
printf '%s\n' "$0: ERROR: grep (syntax?) error! Exiting with code code '$1'." >&2
19+
printf '%s\n' "$0: ERROR: grep (syntax?) error! Exiting with code '$1'." >&2
2020
exit "$1"
2121
fi
2222
}

usr/lib/python3/dist-packages/sanitize_string/sanitize_string.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,19 @@ def main() -> int:
7474
## Read untrusted_string from stdin if needed
7575
if untrusted_string is None:
7676
if sys.stdin is not None:
77-
sys.stdin.reconfigure(errors="ignore") # type: ignore
77+
sys.stdin.reconfigure( # type: ignore
78+
encoding="utf-8", errors="replace", newline="\n"
79+
)
7880
untrusted_string = sys.stdin.read()
7981
else:
8082
## No way to get an untrusted string, print nothing and
8183
## exit successfully
8284
return 0
8385

8486
## Sanitize and print
87+
sys.stdout.reconfigure( # type: ignore
88+
encoding="ascii", errors="replace", newline="\n"
89+
)
8590
assert untrusted_string is not None
8691
sanitized_string: str = sanitize_string(untrusted_string)
8792
if max_string_length is not None:

usr/lib/python3/dist-packages/unicode_show/tests/unicode_show.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def test_clean_ascii(self) -> None:
374374

375375
test_string: str = (
376376
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"
377-
+ "^_`abcdefghjiklmnopqrstuvwxyz{|}~\n"
377+
+ "^_`abcdefghijklmnopqrstuvwxyz{|}~\n"
378378
)
379379
self._test_stdin(
380380
main_func=unicode_show_main,
@@ -476,16 +476,6 @@ def test_pty_color(self) -> None:
476476
stdin_string=test_string,
477477
)
478478

479-
os.environ["NO_COLOR"] = "0"
480-
self._test_stdin_pty(
481-
main_func=unicode_show_main,
482-
argv0=self.argv0,
483-
stdout_string=expect_string_color,
484-
exit_code=1,
485-
args=[],
486-
stdin_string=test_string,
487-
)
488-
489479
def test_unicode_in_filename(self) -> None:
490480
"""
491481
Tests if Unicode characters in filenames are properly sanitized.

usr/lib/python3/dist-packages/unicode_show/unicode_show.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def main() -> int:
174174
global USE_COLOR
175175
USE_COLOR = (
176176
not os.getenv("NOCOLOR")
177-
and os.getenv("NO_COLOR") != "1"
177+
and not os.getenv("NO_COLOR")
178178
and os.getenv("TERM") != "dumb"
179179
and sys.stdout.isatty()
180180
)

0 commit comments

Comments
 (0)