Skip to content

Commit

Permalink
Fix escaping of embedded JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Dec 12, 2022
1 parent 93cb111 commit 7b377a5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/spec-node/dockerCompose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ while sleep 1 & wait $$!; do :; done", "-"${userEntrypoint.map(a => `, ${JSON.st
security_opt:${securityOpts.map(securityOpt => `
- ${securityOpt}`).join('')}` : ''}${additionalLabels.length ? `
labels:${additionalLabels.map(label => `
- ${label.replace(/\$/g, '$$$$')}`).join('')}` : ''}${mounts.length ? `
- '${label.replace(/\$/g, '$$$$').replace(/'/g, '\'\'')}'`).join('')}` : ''}${mounts.length ? `
volumes:${mounts.map(m => `
- ${m.source}:${m.target}`).join('')}` : ''}${gpuResources}${volumeMounts.length ? `
volumes:${volumeMounts.map(m => `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"workspaceFolder": "/workspace",
"postCreateCommand": "touch /postCreateCommand.txt",
"remoteEnv": {
"TEST": "ENV"
"TEST": "ENV",
"TEST_ESCAPING": "{\n \"fo$o\": \"ba'r\"\n}"
}
}
2 changes: 2 additions & 0 deletions src/test/configs/image/.devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"image": "ubuntu:latest",
"postCreateCommand": "touch /postCreateCommand.txt",
"remoteEnv": {
"TEST": "ENV",
"TEST_ESCAPING": "{\n \"fo$o\": \"ba'r\"\n}",
"LOCAL_PATH": "${localEnv:PATH}",
"CONTAINER_PATH": "${containerEnv:PATH}"
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/imageMetadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ describe('Image Metadata', function () {
const metadata = internalGetImageMetadata0(details, true, nullLog);
assert.strictEqual(metadata.length, 1);
assert.ok(metadata[0].remoteEnv);
assert.strictEqual(metadata[0].remoteEnv.TEST, 'ENV');
assert.strictEqual(metadata[0].remoteEnv.TEST_ESCAPING, '{\n "fo$o": "ba\'r"\n}');
await shellExec(`docker exec ${response.containerId} test -f /postCreateCommand.txt`);
await shellExec(`docker rm -f ${response.containerId}`);
});
Expand Down

0 comments on commit 7b377a5

Please sign in to comment.