coreos/fleet — pull request #394 by jonboulle (2014-05-06 00:54:16+00:00)
Title: Go panic when parsing unit files that have line continuations

From the [systemd.unit man page](http://www.freedesktop.org/software/systemd/man/systemd.unit.html):

> Lines ending in a backslash are concatenated with the following line while reading and the backslash is replaced by a space character. This may be used to wrap long lines.

`unit.deserializeUnitFile` currently does not handle this situation properly. If you attempt to feed a unit file with a line continuation in it (backslash at the end of the line) it dies with `panic: runtime error: index out of range`.

This is pretty easy to reproduce in the unit test with a minor change to the test data:
```
$ git diff
diff --git a/unit/file_test.go b/unit/file_test.go
index 7e25193..aeb701a 100644
--- a/unit/file_test.go
+++ b/unit/file_test.go
@@ -16,7 +16,8 @@ Description = Foo
ExecStart=echo "ping";
ExecStop=echo "pong"
# ignore me, too
-ExecStop=echo post
+ExecStop=echo \
+ post

[Fleet]
X-ConditionMachineMetadata=foo=bar
$ go test github.com/coreos/fleet/unit
--- FAIL: TestDeserialize (0.00 seconds)
panic: runtime error: index out of range [recovered]
panic: runtime error: index out of range
… output truncated …
```