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

mdiag.sh can produce invalid JSON #70

Open
adamchel opened this issue Sep 11, 2017 · 0 comments
Open

mdiag.sh can produce invalid JSON #70

adamchel opened this issue Sep 11, 2017 · 0 comments

Comments

@adamchel
Copy link

adamchel commented Sep 11, 2017

I was working with some mdiag.sh output and one of the files contained the following JSON document where "[ESC]" was actually an 0x1B control character.

{
    "ref" : "",
    "host" : "REDACTED",
    "tag" : { "$date" : "2017-09-11T12:50:32.323-0400" },
    "version" : "2.0.4",
    "section" : "timedatectl",
    "ts" : {
        "start" : { "$date" : "2017-09-11T12:51:22.987-0400" },
          "end" : { "$date" : "2017-09-11T12:51:23.015-0400" } },
    "command" : [ "timedatectl" ],
    "rc" : 0,
    "output" : [
        "      Local time: Mon 2017-09-11 12:51:23 EDT",
        "  Universal time: Mon 2017-09-11 16:51:23 UTC",
        "        RTC time: Mon 2017-09-11 12:51:23",
        "       Time zone: America/New_York (EDT, -0400)",
        "     NTP enabled: yes",
        "NTP synchronized: yes",
        " RTC in local TZ: yes",
        "      DST active: yes",
        " Last DST change: DST began at",
        "                  Sun 2017-03-12 01:59:59 EST",
        "                  Sun 2017-03-12 03:00:00 EDT",
        " Next DST change: DST ends (the clock jumps one hour backwards) at",
        "                  Sun 2017-11-05 01:59:59 EDT",
        "                  Sun 2017-11-05 01:00:00 EST",
        "",
        "[ESC]�[1;39mWarning: The system is configured to read the RTC time in the local time zone.",
        "         This mode can not be fully supported. It will create various problems",
        "         with time zone changes and daylight saving time adjustments. The RTC",
        "         time is never updated, it relies on external facilities to maintain it.",
        "         If at all possible, use RTC in UTC by calling",
        "         'timedatectl set-local-rtc 0'�[ESC][0m." ],
    "error" : null
}

Per the JSON specification, control characters are not allowed in strings, so this could probably be fixed by just having the script omit control characters from the JSON output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant