File tree Expand file tree Collapse file tree 5 files changed +60
-25
lines changed
lib/python3/dist-packages/sanitize_string Expand file tree Collapse file tree 5 files changed +60
-25
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python3 -su
2
+
3
+ ## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
4
+ ## See the file COPYING for copying conditions.
5
+
6
+ import sys
7
+
8
+ from sanitize_string .sanitize_string import sanitize_string
9
+
10
+ def print_usage ():
11
+ print (
12
+ "sanitize-string: Usage: sanitize-string string [max_length]" ,
13
+ file = sys .stderr ,
14
+ )
15
+ sys .exit (1 )
16
+
17
+ def main ():
18
+ untrusted_string : str | None = None
19
+ max_string_length : int | None = None
20
+
21
+ if len (sys .argv ) < 2 or len (sys .argv ) > 3 :
22
+ print_usage ()
23
+ untrusted_string = sys .argv [1 ]
24
+
25
+ if len (sys .argv ) == 3 :
26
+ try :
27
+ max_string_length = int (sys .argv [2 ])
28
+ except ValueError :
29
+ print_usage ()
30
+
31
+ assert untrusted_string is not None
32
+
33
+ sanitized_string : str = sanitize_string (untrusted_string )
34
+ if max_string_length is not None :
35
+ sys .stdout .write (sanitized_string [:max_string_length ])
36
+ else :
37
+ sys .stdout .write (sanitized_string )
38
+
39
+ if __name__ == "__main__" :
40
+ main ()
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python3 -su
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python3 -su
2
+
3
+ ## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
4
+ ## See the file COPYING for copying conditions.
5
+
6
+ from strip_markup .strip_markup import strip_markup
7
+ from stdisplay .stdisplay import stdisplay
8
+ from typing import Optional
9
+
10
+ def sanitize_string (
11
+ untrusted_string : str ,
12
+ exclude_sgr : Optional [list [str ]] = None
13
+ ):
14
+ step_one_sanitized_string : str = stdisplay (
15
+ untrusted_string ,
16
+ exclude_sgr = exclude_sgr ,
17
+ )
18
+ final_sanitized_string : str = strip_markup (step_one_sanitized_string )
19
+ return final_sanitized_string
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments