mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-04-28 10:32:12 +00:00
fix #5230: sys: net: properly escape FQDN regex
Due to interpolation, the \. sequence must be double-escaped. Previously, this would result in a non-escaped dot, thus matching much more liberally than it should. Signed-off-by: Christoph Heiss <c.heiss@proxmox.com> [ TL: fix bug # reference in code comments ] Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
1a5665378b
commit
f6bea065f7
@ -7,7 +7,7 @@ use base qw(Exporter);
|
||||
our @EXPORT_OK = qw(parse_ip_address parse_ip_mask parse_fqdn);
|
||||
|
||||
our $HOSTNAME_RE = "(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{,61}?[a-zA-Z0-9])?)";
|
||||
our $FQDN_RE = "(?:${HOSTNAME_RE}\.)*${HOSTNAME_RE}";
|
||||
our $FQDN_RE = "(?:${HOSTNAME_RE}\\.)*${HOSTNAME_RE}";
|
||||
|
||||
my $IPV4OCTET = "(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])";
|
||||
my $IPV4RE = "(?:(?:$IPV4OCTET\\.){3}$IPV4OCTET)";
|
||||
|
@ -309,6 +309,12 @@ mod tests {
|
||||
Fqdn::from(&format!("{}.com", "a".repeat(64))),
|
||||
Err(InvalidPart("a".repeat(64))),
|
||||
);
|
||||
|
||||
// https://bugzilla.proxmox.com/show_bug.cgi?id=5230
|
||||
assert_eq!(
|
||||
Fqdn::from("123@foo.com"),
|
||||
Err(InvalidPart("123@foo".to_owned()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -51,4 +51,7 @@ is_parsed('a' x 63 . '.com', ['a' x 63, 'com']);
|
||||
is_invalid('a' x 250 . '.com', ERR_TOOLONG);
|
||||
is_invalid('a' x 64 . '.com', ERR_ALPHANUM);
|
||||
|
||||
# https://bugzilla.proxmox.com/show_bug.cgi?id=5230
|
||||
is_invalid('123@foo.com', ERR_ALPHANUM);
|
||||
|
||||
done_testing();
|
||||
|
Loading…
Reference in New Issue
Block a user