Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix escapingio handling of \n~\n #8798

Merged
merged 3 commits into from
Sep 1, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,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