From 3d42af06315e3113336873af18aa1c5020c975e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Wed, 16 Sep 2020 18:48:59 +0200 Subject: [PATCH] #5741 - valid DKIM record for bind on create & update mail doman --- interface/web/mail/mail_domain_edit.php | 8 +++++++- interface/web/mail/templates/mail_domain_edit.htm | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php index 77e15b68fc..7409bf0c7c 100644 --- a/interface/web/mail/mail_domain_edit.php +++ b/interface/web/mail/mail_domain_edit.php @@ -219,7 +219,13 @@ class page_action extends tform_actions { $sql = "SELECT domain, dkim_private, dkim_public, dkim_selector FROM mail_domain WHERE domain_id = ?"; $rec = $app->db->queryOneRecord($sql, $app->functions->intval($_GET['id'])); $dns_key = str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$rec['dkim_public']); - $dns_record = $rec['dkim_selector'] . '._domainkey.' . $rec['domain'] . '. 3600 TXT v=DKIM1; t=s; p=' . $dns_key; + + $keyparts = str_split('v=DKIM1; t=s; p=' . $dns_key, 200); + array_walk($keyparts, function(&$value, $key) { $value = '"'.$value.'"'; } ); + $dkim_txt = implode('', $keyparts); + + $dns_record = $rec['dkim_selector'] . '._domainkey.' . $rec['domain'] . '. 3600 IN TXT '.$dkim_txt; + $app->tpl->setVar('dkim_selector', $rec['dkim_selector'], true); $app->tpl->setVar('dkim_private', $rec['dkim_private'], true); $app->tpl->setVar('dkim_public', $rec['dkim_public'], true); diff --git a/interface/web/mail/templates/mail_domain_edit.htm b/interface/web/mail/templates/mail_domain_edit.htm index 42ae8fe280..cb462c9819 100644 --- a/interface/web/mail/templates/mail_domain_edit.htm +++ b/interface/web/mail/templates/mail_domain_edit.htm @@ -134,7 +134,9 @@ dkim_selector : dkim_selector, type : "create_dkim" }, function(data) { - var dns=data['dkim_selector'] + '._domainkey.' + data['domain'] + '. 3600 TXT v=DKIM1; t=s; p=' + data['dns_record']; + var dkim_txt = 'v=DKIM1; t=s; p=' + data['dns_record'].replace(/(\r\n|\n|\r)/gm, ""); + var dns=data['dkim_selector'] + '._domainkey.' + data['domain'] + '. 3600 IN TXT ' + dkim_txt.match(new RegExp('.{1,' + '200' + '}', 'g')).map(chunk => '"' + chunk + '"').join(''); + $("#dkim_selector").val(data.dkim_selector); $("#dkim_public").val(data.dkim_public); $("#dkim_private").val(data.dkim_private); -- GitLab