mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix TXT record parsing
TXT record validation fails to parse the record if it contains spaces. Standard DNS part parser uses a space to divide record parts. A special parser thus need to be implemented for this RR type. https://fedorahosted.org/freeipa/ticket/2306
This commit is contained in:
@@ -1003,6 +1003,10 @@ class TXTRecord(DNSRecord):
|
||||
),
|
||||
)
|
||||
|
||||
def _get_part_values(self, value):
|
||||
# ignore any space in TXT record
|
||||
return (value,)
|
||||
|
||||
_dns_records = (
|
||||
ARecord(),
|
||||
AAAARecord(),
|
||||
@@ -1536,6 +1540,8 @@ class dnsrecord(LDAPObject):
|
||||
u'dnsdata' : dnsvalue
|
||||
}
|
||||
values = param._get_part_values(dnsvalue)
|
||||
if values is None:
|
||||
continue
|
||||
for val_id, val in enumerate(values):
|
||||
if val is not None:
|
||||
dnsentry[parts_params[val_id].name] = val
|
||||
|
||||
@@ -648,6 +648,24 @@ class test_dns(Declarative):
|
||||
},
|
||||
),
|
||||
|
||||
dict(
|
||||
desc='Add TXT record to %r using dnsrecord_add' % (dnsres1),
|
||||
command=('dnsrecord_add', [dnszone1, dnsres1], {'txtrecord': u'foo bar' }),
|
||||
expected={
|
||||
'value': dnsres1,
|
||||
'summary': None,
|
||||
'result': {
|
||||
'objectclass': [u'top', u'idnsrecord'],
|
||||
'dn': unicode(dnsres1_dn),
|
||||
'idnsname': [dnsres1],
|
||||
'arecord': [u'10.10.0.1'],
|
||||
'cnamerecord': [u'foo-1.example.com.'],
|
||||
'kxrecord': [u'1 foo-1'],
|
||||
'txtrecord': [u'foo bar'],
|
||||
},
|
||||
},
|
||||
),
|
||||
|
||||
dict(
|
||||
desc='Delete record %r in zone %r' % (dnsres1, dnszone1),
|
||||
command=('dnsrecord_del', [dnszone1, dnsres1], {'del_all': True }),
|
||||
|
||||
Reference in New Issue
Block a user