diff options
author | Scott Moser <smoser@ubuntu.com> | 2011-04-04 12:45:01 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2011-04-04 12:45:01 -0400 |
commit | 371561772c9073daf9033145b4b2156bc9f0e7dc (patch) | |
tree | 21dc090afcf3b87b7317ca43555ba0c0d0f687a4 /cloudinit/util.py | |
parent | 45794188f06ad3ab990f2c5d32cd2a67341475aa (diff) | |
download | vyos-cloud-init-371561772c9073daf9033145b4b2156bc9f0e7dc.tar.gz vyos-cloud-init-371561772c9073daf9033145b4b2156bc9f0e7dc.zip |
convert some user input from dos to unix (LP: #744965)
If user input is a consumed as a user-script, a boothook, or a upstart
job and appears to be dos-formated, then change it to unix formated
LP: #744965
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index fc4233de..8f6a6b0d 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -389,3 +389,9 @@ def shellify(cmdlist): else: content="%s%s\n" % ( content, str(args) ) return content + +def dos2unix(input): + # find first end of line + pos = input.find('\n') + if pos <= 0 or input[pos-1] != '\r': return(input) + return(input.replace('\r\n','\n')) |