summaryrefslogtreecommitdiff
path: root/cloudinit/cmd/query.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2020-08-24 10:13:52 -0600
committerGitHub <noreply@github.com>2020-08-24 10:13:52 -0600
commitc0450c02b25fe037c702e9bb145fbbaa28a165b1 (patch)
treeb960e46e872b0846220213b1fde6fbdd0db093c8 /cloudinit/cmd/query.py
parentdb86753f81af73826158c9522f2521f210300e2b (diff)
downloadvyos-cloud-init-c0450c02b25fe037c702e9bb145fbbaa28a165b1.tar.gz
vyos-cloud-init-c0450c02b25fe037c702e9bb145fbbaa28a165b1.zip
query: do not handle non-decodable non-gzipped content (#543)
Diffstat (limited to 'cloudinit/cmd/query.py')
-rw-r--r--cloudinit/cmd/query.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/cloudinit/cmd/query.py b/cloudinit/cmd/query.py
index 03b77c17..07db9552 100644
--- a/cloudinit/cmd/query.py
+++ b/cloudinit/cmd/query.py
@@ -86,14 +86,11 @@ def load_userdata(ud_file_path):
@returns: String of uncompressed userdata if possible, otherwise bytes.
"""
+ bdata = util.load_file(ud_file_path, decode=False)
try:
- return util.load_file(ud_file_path)
+ return bdata.decode('utf-8')
except UnicodeDecodeError:
- encoded_data = util.load_file(ud_file_path, decode=False)
- try:
- return util.decomp_gzip(encoded_data, quiet=False)
- except util.DecompressionError:
- return encoded_data
+ return util.decomp_gzip(bdata, quiet=False, decode=True)
def handle_args(name, args):