Only try to convert exact domains using the IDN library.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-02-14 17:24:01 +01:00
parent 843e46d84a
commit b2cc349abf
4 changed files with 32 additions and 19 deletions

View File

@@ -21,9 +21,12 @@ $domains = preg_split('/\s+/', trim($_POST['domain']));
$comment = trim($_POST['comment']);
// Convert domain name to IDNA ASCII form for international domains
foreach($domains as &$domain)
{
$domain = idn_to_ascii($domain);
// Do this only for exact domains, not for regex filters
if ($list === "white" || $list === "black") {
foreach($domains as &$domain)
{
$domain = idn_to_ascii($domain);
}
}
// Only check domains we add to the exact lists.

View File

@@ -30,12 +30,14 @@ function getTableContent($type) {
while($results !== false && $res = $results->fetchArray(SQLITE3_ASSOC))
{
$utf8_domain = idn_to_utf8($res['domain']);
// Convert domain name to international form
// if applicable
if($res['domain'] !== $utf8_domain)
{
$res['domain'] = $utf8_domain.' ('.$res['domain'].')';
if ($res['type'] === ListType::whitelist || $res['type'] === ListType::blacklist) {
$utf8_domain = idn_to_utf8($res['domain']);
// Convert domain name to international form
// if applicable
if($res['domain'] !== $utf8_domain)
{
$res['domain'] = $utf8_domain.' ('.$res['domain'].')';
}
}
array_push($entries, $res);
}

View File

@@ -346,12 +346,14 @@ if ($_POST['action'] == 'get_groups') {
array_push($groups, $gres['group_id']);
}
$res['groups'] = $groups;
$utf8_domain = idn_to_utf8($res['domain']);
// Convert domain name to international form
// if applicable
if($res['domain'] !== $utf8_domain)
{
$res['domain'] = $utf8_domain.' ('.$res['domain'].')';
if ($res['type'] === ListType::whitelist || $res['type'] === ListType::blacklist) {
$utf8_domain = idn_to_utf8($res['domain']);
// Convert domain name to international form
// if applicable
if($res['domain'] !== $utf8_domain)
{
$res['domain'] = $utf8_domain.' ('.$res['domain'].')';
}
}
array_push($data, $res);
}
@@ -371,10 +373,10 @@ if ($_POST['action'] == 'get_groups') {
$type = intval($_POST['type']);
// Convert domain name to IDNA ASCII form for international domains
$domain = idn_to_ascii($_POST['domain']);
if($type === ListType::whitelist || $type === ListType::blacklist)
{
if ($type === ListType::whitelist || $type === ListType::blacklist) {
// Convert domain name to IDNA ASCII form for international domains
$domain = idn_to_ascii($_POST['domain']);
// If adding to the exact lists, we convert the domain lower case and check whether it is valid
$domain = strtolower($domain);
if(filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false)