diff --git a/data/import.php b/data/import.php index 610b3a2..befd48e 100644 --- a/data/import.php +++ b/data/import.php @@ -1,23 +1,28 @@ $node) { - $key = is_integer($key) ? '' : '\''.$key.'\' => '; - $value = (is_array($node)) ? arrayToCode($node, $level) : str_replace("'", "\'", $node); - $output .= $tabs.$key.((is_string($node)) ? '\''.$value.'\'' : $value).(($key !== array_key_last($data)) ? ', ' : '')."\n"; + $key = is_integer($key) ? '' : var_export($key, true) . ' => '; + $value = is_array($node) ? arrayToCode($node, $level) : var_export($node, true); + $output .= $tabs.$key.$value.",\n"; } $level--; - $tabs = str_repeat ("\t", $level); + $tabs = str_repeat("\t", $level); $output .= $tabs.']'; @@ -34,18 +39,18 @@ function arrayToCode(array $data, $level = 0):string { $comments = []; continue; } - + if(mb_strpos($line, '===END ICANN DOMAINS===')) { $type = null; continue; } - + if(mb_strpos($line, '===BEGIN PRIVATE DOMAINS===')) { $type = 'PRIVATE'; $comments = []; continue; } - + if(mb_strpos($line, '===END PRIVATE DOMAINS===')) { $type = null; continue; @@ -69,4 +74,8 @@ function arrayToCode(array $data, $level = 0):string { $comments = []; } +if (!isset($domains['com'])) { + throw new RuntimeException(".com is missing from public suffix list; it must be corrupted"); +} + file_put_contents(__DIR__.'/data.php', "