Double quotes being added to return answers

Hi,

We have the Python module setup to do lookups and return answers,
looks like everything is working except on a TXT record, unbound is
double quoting each group of text and this not a valid SPF entry for
example.

"v=spf1" "include:_spf.mydom.com" "include:_spf.otherdom.com" "~all"
instead of just one set of quotes around the entire string.

That's what im getting returned, on the python/unbound side we have a
simple msg.answer.append setup:

msg = DNSMessage(qstate.qinfo.qname_str, RR_TYPE_TXT, RR_CLASS_IN,
PKT_QR | PKT_AA)

msg.answer.append("%s %d IN TXT %s" %
(qstate.qinfo.qname_str,txt['ttl'],str(txt['content'])))

The txt['content'] source has no double quotes. I have tried enclosing
it in double quotes as well, same behavior. Python does not appear to
be adding the quotes, it's something on the unbound side from what i
can tell.

I did some searching and I can't find anyone else who has seen this
issue, so not sure what else to try.

Any pointers would be great.

Thanks!

Hi Brad,

Unbound internally deals with TXT records in wireformat, double quotes
are not added or removed. I think the quotes you see are because of
multiple string sections in the TXT wireformat (each gets printed with
quotes around them).

The python .append function takes a text string and converts it to
wireformat. I think the lack of quotes in there makes the parser use
whitespace to separate strings? Try the append with quotes around
your content: "%s %d IN TXT \"%s\"" (if that is valid python to
escape with \").

Best regards, Wouter

Hi Wouter,

Thanks for the fast response.

That was the issue, if the string has no spaces and you add the quotes
then you get the literally quotes and slash in the return, so adding
that only when it has spaces works perfect.

Thanks again!