This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
Prevent semicolon in last value breaking rest clapi serialization #6234
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.
At the moment, trying to use the REST API to retrieve a value containing a semicolon causes the serialization to break. This is broken on the default install by the host-notify-by-jabber command, which contains the HTML entities
'
.The problem is caused by the semicolon being used to split the values. This causes there to be more values than headers, and
array_combine
then returnsfalse
for that item.To get around this, this PR checks for there being more values than headers, and if so, recombines all of the last items into one value. This catches the case where the last item contains a semicolon (e.g. the "line" parameter of command). This will not work if semicolon is present in any field other than the last.
This isn't an ideal solution - it would be better to either have a way to escape semicolons in the CLAPI output, or preventing semicolons being added (unlikely to be possible for things like commands).
Fixes #6110