dig YAML output does not quote strings containing ": "
Summary
I'm using the +yaml
option for dig
for machine-parseable output and encountered a host emitting TXT records that contain ": ". These records are not quoted for some reason. When parsing the YAML output with libyaml, it misinterprets such records as a mapping instead of a string.
BIND version affected
DiG 9.19.25-dev
BIND 9.19.25-dev (Development Release) <id:392e719>
Steps to reproduce
dig @8.8.8.8 +yaml vlsu.ru TXT
- Alternatively,
ruby -e 'require "yaml";puts YAML.safe_load(`dig @8.8.8.8 +yaml vlsu.ru TXT`, permitted_classes: [Time])[0]["message"]["response_message_data"]["ANSWER_SECTION"]'
What is the current bug behavior?
Output of the 1st command:
[...]
ANSWER_SECTION:
- vlsu.ru. 3427 IN TXT "yandex-verification: f248f83d5303e97d"
- vlsu.ru. 3427 IN TXT "v=spf1 mx -all"
- vlsu.ru. 3427 IN TXT "google-site-verification=3LAzNkhE9EXeAevwahpx_ZhTIbKtkKBb5mXR5nxlP30"
Output of the 2nd command:
vlsu.ru. 3523 IN TXT "v=spf1 mx -all"
vlsu.ru. 3523 IN TXT "google-site-verification=3LAzNkhE9EXeAevwahpx_ZhTIbKtkKBb5mXR5
nxlP30"
{"vlsu.ru. 3523 IN TXT \"yandex-verification"=>"f248f83d5303e97d\""}
What is the expected correct behavior?
Output of the 1st command:
[...]
ANSWER_SECTION:
- 'vlsu.ru. 3427 IN TXT "yandex-verification: f248f83d5303e97d"'
- vlsu.ru. 3427 IN TXT "v=spf1 mx -all"
- vlsu.ru. 3427 IN TXT "google-site-verification=3LAzNkhE9EXeAevwahpx_ZhTIbKtkKBb5mXR5nxlP30"
Output of the 2nd command:
vlsu.ru. 3523 IN TXT "v=spf1 mx -all"
vlsu.ru. 3523 IN TXT "google-site-verification=3LAzNkhE9EXeAevwahpx_ZhTIbKtkKBb5mXR5
nxlP30"
vlsu.ru. 3523 IN TXT "yandex-verification: f248f83d5303e97d"
Relevant configuration files
None
Relevant logs
None