diff options
author | joshuabuildsthings <joshuabuildsthings@users.noreply.github.com> | 2023-11-07 02:06:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-07 07:06:43 +0000 |
commit | aec5c9ef6ecfab1c1e5b51778e5a0045dcf00b03 (patch) | |
tree | d27ceb412d09ac45a2e6ec59516497601ad3d92e | |
parent | 52190fb5ffe2fd9f97797d99f9516a28918d68d3 (diff) |
Hotfix/reports model render report sanitize inputs (#5669)
* Adding more robust special character handling to create_output_path().Addresses https://github.com/OpenBB-finance/OpenBBTerminal/issues/5299
* Running black linter on code to conform to OBB style guides.
---------
Co-authored-by: James Maslek <jmaslek11@gmail.com>
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
-rw-r--r-- | openbb_terminal/reports/reports_model.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/openbb_terminal/reports/reports_model.py b/openbb_terminal/reports/reports_model.py index 7b5facf57b0..8003117df57 100644 --- a/openbb_terminal/reports/reports_model.py +++ b/openbb_terminal/reports/reports_model.py @@ -279,7 +279,26 @@ def create_output_path(input_path: str, parameters_dict: Dict[str, Any]) -> str: + "_" + f"{report_name}{args_to_output}" ) - report_output_name = report_output_name.replace(".", "_") + + special_chars = [ + ".", + ";", + ":", + "!", + "*", + " ", + "^", + "<", + ">", + '"', + "/", + "|", + "?", + "\\", + ] + for char in special_chars: + report_output_name = report_output_name.replace(char, "_") + output_path = str( get_current_user().preferences.USER_REPORTS_DIRECTORY / report_output_name ) |