Correct absolute paths without . in some cases

This commit is contained in:
Jamie Cameron
2008-06-15 22:07:56 +00:00
parent dadf6a72f3
commit 0a53644430
3 changed files with 22 additions and 2 deletions

View File

@@ -75,3 +75,4 @@ Spaces are now allowed in Host Information records.
---- Changes since 1.420 ----
The default TTL for multiple zones can now be changed on the Update Records in Zones page.
When adding a cluster slave server, multiple views can be entered to have slave zones created in all of them.
Record names or values entered like ns.foo.com in the domain foo.com automatically have a . added to make them absolute as the user presumably expected, rather than being coverted to ns.foo.com.foo.com.

View File

@@ -726,11 +726,19 @@ else {
}
# convert_to_absolute(short, origin)
# Make a short name like foo a fully qualified name like foo.domain.com.
sub convert_to_absolute
{
local ($name, $origin) = @_;
if ($name eq $origin ||
$name =~ /\.\Q$origin\E$/) {
# Name already ends in domain name - add . automatically, so we don't
# re-append the domain name.
$name .= ".";
}
local $rv = $name eq "" ? "$origin." :
$name !~ /\.$/ ? "$name.$origin." : $name;
$name eq "@" ? "$origin." :
$name !~ /\.$/ ? "$name.$origin." : $name;
$rv =~ s/\.+$/\./;
return $rv;
}

View File

@@ -94,7 +94,7 @@ if ($in{'delete'}) {
exit;
}
# parse inputs
# Create values string based on inputs
if (!$in{'ttl_def'}) {
$in{'ttl'} =~ /^\d+$/ ||
&error(&text('edit_ettl', $in{'ttl'}));
@@ -106,6 +106,7 @@ for($i=1; defined($in{"value$i"}); $i++) {
}
$vals =~ s/^\s+//;
$vals =~ s/\s+$//;
if ($in{'type'} eq "PTR" && $reverse) {
# a reverse address
local($ipv4);
@@ -182,16 +183,26 @@ else {
elsif ($in{'type'} eq "NS") {
&valname($vals) ||
&error(&text('edit_ens', $vals));
if ($vals =~ /\.\Q$in{'origin'}\E$/) {
# Make absolute
$vals .= ".";
}
}
elsif ($in{'type'} eq "CNAME") {
&valname($vals) || $vals eq '@' ||
&error(&text('edit_ecname', $vals));
if ($vals =~ /\.\Q$in{'origin'}\E$/) {
$vals .= ".";
}
}
elsif ($in{'type'} eq "MX") {
&valname($in{'value1'}) ||
&error(&text('edit_emx', $in{'value1'}));
$in{'value0'} =~ /^\d+$/ ||
&error(&text('edit_epri', $in{'value0'}));
if ($vals =~ /\.\Q$in{'origin'}\E$/) {
$vals .= ".";
}
}
elsif ($in{'type'} eq "HINFO") {
$in{'value0'} =~ /\S/ ||