Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cli/openbb_cli/controllers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,10 @@ def parse_and_split_input(an_input: str, custom_filters: list) -> list[str]:
return list(filter(None, commands))
matching_placeholders = [tag for tag in placeholders if tag in command]
if len(matching_placeholders) > 0:
restored = command
for tag in matching_placeholders:
commands[command_num] = command.replace(tag, placeholders[tag])
restored = restored.replace(tag, placeholders[tag])
commands[command_num] = restored
return list(filter(None, commands))


Expand Down
16 changes: 16 additions & 0 deletions cli/tests/test_queue_multiple_file_arguments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Queued commands must not leak internal placeholder tokens."""

from openbb_cli.controllers.utils import parse_and_split_input


def test_multiple_paths_in_one_queued_command():
command = "load -f /tmp/first.csv --file /tmp/second.csv"
assert parse_and_split_input(command + "/echo done", []) == [command, "echo done"]


def test_custom_protected_arguments_are_all_restored():
command = "echo [first/path] [second/path]"
assert parse_and_split_input(command + "/echo done", [r"\[[^\]]+\]"]) == [
command,
"echo done",
]