Skip to content

Commit

Permalink
Merge pull request #8798 from hashicorp/b-esccaping-newline
Browse files Browse the repository at this point in the history
Fix escapingio handling of `\n~\n`
  • Loading branch information
Mahmood Ali committed Sep 1, 2020
2 parents 150e0e2 + 4820159 commit 81f9c0d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BUG FIXES:
* csi: Fixed a bug where querying CSI volumes would cause a panic if an allocation that claimed the volume had been garbage collected but the claim was not yet dropped. [[GH-8735](https://github.com/hashicorp/nomad/issues/8735)]
* deployments (Enterprise): Fixed a bug where counts could not be changed in the web UI for multiregion jobs. [[GH-8685](https://github.com/hashicorp/nomad/issues/8685)]
* deployments (Enterprise): Fixed a bug in multi-region deployments where a region that was dropped from the jobspec was not deregistered. [[GH-8763](https://github.com/hashicorp/nomad/issues/8763)]
* exec: Fixed a bug causing escape characters to be missed in special cases [[GH-8798](https://github.com/hashicorp/nomad/issues/8798)]
* plan: Fixed a bug where plans always included a change for the `NomadTokenID`. [[GH-8559](https://github.com/hashicorp/nomad/issues/8559)]

## 0.12.3 (August 13, 2020)
Expand Down
7 changes: 7 additions & 0 deletions helper/escapingio/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func (r *reader) pipe() {
bw.WriteByte(r.escapeChar)
bw.WriteByte(rb[0])
bw.Flush()
if rb[0] == '\n' || rb[0] == '\r' {
state = sLookEscapeChar
}
}
}
}
Expand Down Expand Up @@ -137,6 +140,10 @@ START:
bw.Write(buf[wi:i])
i = i + 2
wi = i
} else if nc == '\n' || nc == '\r' {
i = i + 2
s = sLookEscapeChar
goto START
} else {
i = i + 2
// need to write everything keep going
Expand Down
1 change: 1 addition & 0 deletions helper/escapingio/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestEscapingReader_Static(t *testing.T) {
{"\n~.", "\n", "."},
{"~", "~", ""},
{"\r~.", "\r", "."},
{"b\n~\n~.q", "b\n~\nq", "."},
}

for _, c := range cases {
Expand Down

0 comments on commit 81f9c0d

Please sign in to comment.