engine/{scriptv4,scriptrunner}: fix v4 to v5 script conversion and v5 scriptrunner #1889
+6
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reported: https://www.qlcplus.org/forum/viewtopic.php?t=18935
Describe the bug / To Reproduce / Expected behaviour
Scriptfunction and paste the following code:with
cmdlinebeing the following helper bash script:(change the paths as necessary).
output.txtmatch:Bug A: The (double) quotes in the last argument of the first line were not escaped during the script conversion from v4 to v5. This is an issue and prevents the script from running.
n\"op\"q). The syntax checker should now report: “No errors found.”output.txtmatch:The first line should be correct since it is equivalent to the output from QLC+ v4.
However, the second line (the example from the linked forum thread) is wrong, as it does not pass any of the specified arguments to the bash script.
Bug B: If an argument does not contain spaces, but is still enclosed in single quotes (as are all arguments in scripts converted from v4), they are skipped when the script is executed.
Problem Analysis
Bug A
The conversion code only checks whether an argument begins with quotes and then threats it accordingly. However, quotes contained within an argument are not take into account in any way. source
Bug B
The issue lies in the
ScriptRunner::systemCommandfunction. Assuming that the current input for this function is the second line of the above test script, during the first round of this loop, the first argument begins with a single quote and is therefore written (with only the first character, the opening quotation mark, removed) to the cleanedmultiPartArgstring. In the next iteration (whentokencontains the second argument, which also begins with a single quote),multiPartArgis cleaned and the second argument is written to it. This continues for all arguments.Therefore, at the end of the loop, no argument has been written into
programArgsand the system command is launched without any arguments.Proposed Solutions
Bug A
Add a
replacecall to also escape quotes in the middle of an argumentBug B
Add another
if-case beforeif (token.startsWith("'"))(line 450) and change the old line 450 toelse ifThe new
if-case checks whether thetoken(argument) starts and ends with a single quote (and does not contain a space, which is implicitly given since alltokenweresplitfromcommandby a space).If this is true, simply remove the single quotes at the beginning and end, and then add the resulting string to the
programArgslist.