Splitting commands properly without losing double quoted strings
This commit is contained in:
parent
5d1ae402b6
commit
7116b582e8
|
@ -73,19 +73,7 @@ Email Subject ApprvlApprvr1 PIComputingID
|
|||
message="Email script requires at least one subject argument. The "
|
||||
"name of the variable in the task data that contains subject"
|
||||
" to process. Multiple arguments are accepted.")
|
||||
|
||||
subject_index = 0
|
||||
subject = args[subject_index]
|
||||
if subject.startswith('"') and not subject.endswith('"'):
|
||||
# Multi-word subject
|
||||
subject_index += 1
|
||||
next_word = args[subject_index]
|
||||
while not next_word.endswith('"'):
|
||||
subject = ' '.join((subject, next_word))
|
||||
subject_index += 1
|
||||
next_word = args[subject_index]
|
||||
subject = ' '.join((subject, next_word))
|
||||
subject = subject.replace('"', '')
|
||||
subject = args[0]
|
||||
if not isinstance(subject, str):
|
||||
raise ApiError(code="invalid_argument",
|
||||
message="The Email script requires 1 argument. The "
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import re
|
||||
import shlex
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
from datetime import datetime
|
||||
from typing import List
|
||||
|
@ -36,7 +37,9 @@ class CustomBpmnScriptEngine(BpmnScriptEngine):
|
|||
|
||||
This allows us to reference custom code from the BPMN diagram.
|
||||
"""
|
||||
commands = script.split(" ")
|
||||
# Shlex splits the whole string while respecting double quoted strings within
|
||||
commands = shlex.split(script)
|
||||
printable_comms = commands
|
||||
path_and_command = commands[0].rsplit(".", 1)
|
||||
if len(path_and_command) == 1:
|
||||
module_name = "crc.scripts." + self.camel_to_snake(path_and_command[0])
|
||||
|
|
Loading…
Reference in New Issue