Skip to content
Merged
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
10 changes: 10 additions & 0 deletions features/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,13 @@ Feature: Test this extension
"""
scanned=1
"""

Scenario: Test jq JSON strings preserve escaped quotes
When set the response to:
"""
{"data":{"policy":{"value":"{\"allowGroups\":[\"reviewers\"],\"denyGroups\":[]}"}}}
"""
And sending "POST" to "/"
Then the response should be a JSON array with the following mandatory values
| key | value |
| (jq).data.policy.value | {\"allowGroups\":[\"reviewers\"],\"denyGroups\":[]} |
4 changes: 4 additions & 0 deletions src/NextcloudApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ private function runJsonQuery(string $json, string $filter): mixed {
$process->mustRun();
$output = trim($process->getOutput());
$decoded = json_decode($output, true);
if (is_string($decoded)) {
// Preserve the escaped jq string representation used by the legacy mapper.
return substr($output, 1, -1);
}
return json_last_error() === JSON_ERROR_NONE ? $decoded : $output;
}

Expand Down
Loading