Skip to content

Commit

Permalink
Fix #33 Ignore content after a JSON's closing bracket
Browse files Browse the repository at this point in the history
Signed-off-by: Remy Suen <remy.suen@gmail.com>
  • Loading branch information
rcjsuen committed Apr 3, 2018
1 parent 54d1f7a commit 295e7ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
### Fixed
- fix incorrect validation error if a COPY uses JSON arguments and its last string argument is correctly defined as a folder ([#29](https://github.com/rcjsuen/dockerfile-utils/issues/29))
- fix incorrect validation error if an ADD uses JSON arguments and its last string argument is correctly defined as a folder ([#30](https://github.com/rcjsuen/dockerfile-utils/issues/30))
- skip validation of content after a JSON's closing bracket ([#33](https://github.com/rcjsuen/dockerfile-utils/issues/33))

## [0.0.7] - 2018-03-01
### Fixed
Expand Down
1 change: 1 addition & 0 deletions src/dockerValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ export class Validator {
break argsCheck;
} else if (last !== ',') {
last = null;
break argsCheck;
}
}
break;
Expand Down
18 changes: 12 additions & 6 deletions test/dockerValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3036,6 +3036,18 @@ describe("Docker Validator Tests", function() {

diagnostics = validateDockerfile("FROM busybox\nSHELL [ \"\\\\[\" ]");
assert.equal(diagnostics.length, 0);

diagnostics = validateDockerfile("FROM busybox\nSHELL [ \"/bin/sh\" ] ]");
assert.equal(diagnostics.length, 0);

diagnostics = validateDockerfile("FROM busybox\nSHELL [ \"/bin/sh\" ] [");
assert.equal(diagnostics.length, 0);

diagnostics = validateDockerfile("FROM busybox\nSHELL [ \"/bin/sh\" ] ,");
assert.equal(diagnostics.length, 0);

diagnostics = validateDockerfile("FROM busybox\nSHELL [ \"/bin/sh\" ] a");
assert.equal(diagnostics.length, 0);
});

it("invalid escape", function() {
Expand Down Expand Up @@ -3082,12 +3094,6 @@ describe("Docker Validator Tests", function() {
assertShellJsonForm(diagnostics[0], 1, 6, 1, 17);
});

it("double ending ]", function() {
let diagnostics = validateDockerfile("FROM busybox\nSHELL [ \"/bin/sh\" ] ]");
assert.equal(diagnostics.length, 1);
assertShellJsonForm(diagnostics[0], 1, 6, 1, 21);
});

it("comma with EOF", function() {
let diagnostics = validateDockerfile("FROM busybox\nSHELL [ \"/bin/sh\",");
assert.equal(diagnostics.length, 1);
Expand Down

0 comments on commit 295e7ab

Please sign in to comment.