Trim whitespace from unit files while parsing

Fixes: https://github.com/containers/podman/issues/18979

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2023-06-23 07:55:12 -04:00
parent 384638861b
commit bc5269f187
4 changed files with 5 additions and 4 deletions

View File

@ -373,7 +373,7 @@ func (p *UnitFileParser) flushPendingComments(toComment bool) {
func nextLine(data string, afterPos int) (string, string) {
rest := data[afterPos:]
if i := strings.Index(rest, "\n"); i >= 0 {
return data[:i+afterPos], data[i+afterPos+1:]
return strings.TrimSpace(data[:i+afterPos]), data[i+afterPos+1:]
}
return data, ""
}