Commit 6c9fa6e7 authored by Michael Herold's avatar Michael Herold
Browse files

[dns] Fixes bugs with proper txt rdata handling

parent 550940ca
......@@ -150,11 +150,27 @@ class CustomCreate extends Window
}
}
public static function getRdata($type, gui\FormPost $form)
{
$keys = self::TYPE_KEYS;
// without '_p' prefix
$jsonData = $form->getVal($keys[$type], '');
// manual adjustemnts for some types
if ($type == 'TXT')
// TODO: support strings > 255, currently carnivora will barf
$jsonData['txtdata'] = [$jsonData['txtdata']];
// convert to json
return json_encode($jsonData);
}
protected function handleSubmit($domain, $type, gui\FormPost $form)
{
if ($form->correctSubmitted()) {
$keys = self::TYPE_KEYS;
$rdata = json_encode($form->getVal($keys[$type], ''));
$rdata = self::getRdata($type, $form);
$params = ['p_registered' => $domain, 'p_type' => $type, 'p_rdata' => $rdata]
+ $form->getVal(['domain', 'ttl']);
......@@ -277,9 +293,9 @@ class CustomCreate extends Window
protected function formTxt()
{
$cname = new form\FieldText('txtdata', _('Text String'));
$cname->setPlaceholder('');
$txt = new form\FieldText('txtdata', _('Text String'));
$txt->setPlaceholder('');
return $cname;
return $txt;
}
}
......@@ -50,6 +50,9 @@ class CustomDetails extends Window
$data = $raw + (array) json_decode($raw['rdata']);
if (isset($data['txtdata']))
$data['txtdata'] = implode('', $data['txtdata']);
$window->getForm()->setStoredValues($data);
$x = (new CustomCreate($this->module))->formType($domain, $data['type']);
......@@ -73,8 +76,7 @@ class CustomDetails extends Window
protected function handleSubmit($recordId, $type, gui\FormPost $form)
{
if ($form->correctSubmitted()) {
$keys = CustomCreate::TYPE_KEYS;
$rdata = json_encode($form->getVal($keys[$type], ''));
$rdata = CustomCreate::getRdata($type, $form);
$params = ['p_id' => $recordId, 'p_rdata' => $rdata] + $form->getVal(['ttl']);
......
......@@ -186,7 +186,8 @@ class RegisteredDetails extends Window
$rdata = (array) json_decode($record['rdata']);
ksort($rdata);
foreach ($rdata as $key => $value) {
$ul->addLine(new html\Str(sprintf('%s = %s', $key, $value)));
$ul->addLine(new html\Str(sprintf('%s = %s', $key,
print_r($value, true))));
}
$span->addChild(new html\Str($domain.' '.$record['type']));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment