diff --git a/cyclonedx_py/client.py b/cyclonedx_py/client.py index cc8031ea..908f5fe8 100644 --- a/cyclonedx_py/client.py +++ b/cyclonedx_py/client.py @@ -273,10 +273,10 @@ def _get_input_parser(self) -> BaseParser: 'When using input from Conda JSON, you need to pipe input via STDIN') elif self._arguments.input_from_pip: self._arguments.input_source = open(os.path.join(current_directory, 'Pipfile.lock'), - 'rt', encoding="UTF-8") + 'rt', encoding="UTF-8", errors='replace') elif self._arguments.input_from_poetry: self._arguments.input_source = open(os.path.join(current_directory, 'poetry.lock'), - 'rt', encoding="UTF-8") + 'rt', encoding="UTF-8", errors='replace') elif self._arguments.input_from_requirements: self._arguments.input_source = open(os.path.join(current_directory, 'requirements.txt'), 'rb') else: @@ -297,7 +297,7 @@ def _get_input_parser(self) -> BaseParser: input_data = input_data.decode(input_encoding) except ValueError: # last resort: try utf8 and hope for the best - input_data = input_data.decode('utf-8', 'backslashreplace') + input_data = input_data.decode('utf-8', 'replace') input_data_fh.close() if self._arguments.input_from_conda_explicit: diff --git a/cyclonedx_py/parser/pipenv.py b/cyclonedx_py/parser/pipenv.py index 5c614c17..191df678 100644 --- a/cyclonedx_py/parser/pipenv.py +++ b/cyclonedx_py/parser/pipenv.py @@ -73,7 +73,7 @@ def __init__( debug_message: DebugMessageCallback = quiet ) -> None: debug_message('open file: {}', pipenv_lock_filename) - with open(pipenv_lock_filename) as plf: + with open(pipenv_lock_filename, encoding="UTF-8", errors='replace') as plf: super(PipEnvFileParser, self).__init__( pipenv_contents=plf.read(), use_purl_bom_ref=use_purl_bom_ref, debug_message=debug_message diff --git a/cyclonedx_py/parser/poetry.py b/cyclonedx_py/parser/poetry.py index 1157cd48..04b7df64 100644 --- a/cyclonedx_py/parser/poetry.py +++ b/cyclonedx_py/parser/poetry.py @@ -87,7 +87,7 @@ def __init__( debug_message: DebugMessageCallback = quiet ) -> None: debug_message('open file: {}', poetry_lock_filename) - with open(poetry_lock_filename, errors='backslashreplace') as plf: + with open(poetry_lock_filename, encoding="UTF-8", errors='replace') as plf: super(PoetryFileParser, self).__init__( poetry_lock_contents=plf.read(), use_purl_bom_ref=use_purl_bom_ref, debug_message=debug_message