File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1919from e4s_cl .cli import UnknownCommandError , arguments
2020from e4s_cl .cli .command import AbstractCommand
2121from e4s_cl .cli .commands .launch import COMMAND as LAUNCH_COMMAND
22+ from e4s_cl .util import sanitize_args
2223
2324LOGGER = logger .get_logger (__name__ )
2425
@@ -215,6 +216,7 @@ def main(self, argv):
215216 else :
216217 parse_method = self ._py39_parse
217218
219+ argv = sanitize_args (argv )
218220 args = parse_method (argv )
219221
220222 self .set_log_level (args )
Original file line number Diff line number Diff line change 1212from pathlib import Path
1313from hashlib import sha256
1414import json
15+ import unicodedata
1516from typing import (
1617 Any ,
1718 Callable ,
@@ -583,3 +584,23 @@ def prepend_library_path(path: Union[str, Path]):
583584 """
584585 env = os .environ .get ("LD_LIBRARY_PATH" , [])
585586 os .environ ["LD_LIBRARY_PATH" ] = os .pathsep .join ([str (path ), * env ])
587+
588+
589+ def sanitize_args (argv : List [str ]) -> List [str ]:
590+ """
591+ Cleans a list of command-line arguments by normalizing Unicode characters
592+ and collapsing all whitespace to a single space.
593+ """
594+ sanitized_argv = []
595+ for arg in argv :
596+ if isinstance (arg , str ):
597+ # NFKC normalization
598+ normalized_str = unicodedata .normalize ('NFKC' , arg )
599+ # Collapse all whitespace and strip ends
600+ sanitized_arg = ' ' .join (normalized_str .split ())
601+ sanitized_argv .append (sanitized_arg )
602+ else :
603+ # Preserve non-string arguments
604+ sanitized_argv .append (arg )
605+
606+ return sanitized_argv
You can’t perform that action at this time.
0 commit comments