From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 2/5] common: fqdn: implement case-insensitive comparison as per RFC 952
Date: Thu, 15 Feb 2024 13:39:35 +0100 [thread overview]
Message-ID: <20240215124004.1197676-3-c.heiss@proxmox.com> (raw)
In-Reply-To: <20240215124004.1197676-1-c.heiss@proxmox.com>
Multiple DNS-related RFCs (notably RFC 952, RFC 1035 and RFC 4343)
reinforce that FQDN must not be case-sensitive.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
proxmox-installer-common/src/utils.rs | 28 ++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/proxmox-installer-common/src/utils.rs b/proxmox-installer-common/src/utils.rs
index 067e025..0ed7438 100644
--- a/proxmox-installer-common/src/utils.rs
+++ b/proxmox-installer-common/src/utils.rs
@@ -154,7 +154,7 @@ impl fmt::Display for FqdnParseError {
///
/// Some terminology:
/// - "label" - a single part of a FQDN, e.g. <label>.<label>.<tld>
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Clone, Debug, Eq)]
pub struct Fqdn {
parts: Vec<String>,
}
@@ -257,6 +257,26 @@ impl<'de> Deserialize<'de> for Fqdn {
}
}
+impl PartialEq for Fqdn {
+ fn eq(&self, other: &Self) -> bool {
+ // Case-insensitive comparison, as per RFC 952 "ASSUMPTIONS",
+ // RFC 1035 sec. 2.3.3. "Character Case" and RFC 4343 as a whole
+ let a = self
+ .parts
+ .iter()
+ .map(|s| s.to_lowercase())
+ .collect::<Vec<String>>();
+
+ let b = other
+ .parts
+ .iter()
+ .map(|s| s.to_lowercase())
+ .collect::<Vec<String>>();
+
+ a == b
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -309,4 +329,10 @@ mod tests {
"foo.example.com"
);
}
+
+ #[test]
+ fn fqdn_compare() {
+ assert_eq!(Fqdn::from("example.com"), Fqdn::from("ExAmPle.Com"));
+ assert_eq!(Fqdn::from("ExAmPle.Com"), Fqdn::from("example.com"));
+ }
}
--
2.43.0
next prev parent reply other threads:[~2024-02-15 12:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 12:39 [pve-devel] [PATCH installer 0/5] proxinstall, tui: improve hostname/FQDN validation Christoph Heiss
2024-02-15 12:39 ` [pve-devel] [PATCH installer 1/5] common: fqdn: do not allow overlong FQDNs as per Debian spec Christoph Heiss
2024-02-15 12:39 ` Christoph Heiss [this message]
2024-02-23 16:10 ` [pve-devel] [PATCH installer 2/5] common: fqdn: implement case-insensitive comparison as per RFC 952 Thomas Lamprecht
2024-02-15 12:39 ` [pve-devel] [PATCH installer 3/5] proxinstall: avoid open-coding FQDN sanity check Christoph Heiss
2024-02-15 12:39 ` [pve-devel] [PATCH installer 4/5] sys: net: do not allow overlong FQDNs as per RFCs and Debian spec Christoph Heiss
2024-02-15 12:39 ` [pve-devel] [PATCH installer 5/5] fix #5230: sys: net: properly escape FQDN regex Christoph Heiss
2024-02-23 16:27 ` Thomas Lamprecht
2024-02-26 9:04 ` Christoph Heiss
2024-02-23 16:31 ` [pve-devel] applied-series: [PATCH installer 0/5] proxinstall, tui: improve hostname/FQDN validation Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240215124004.1197676-3-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal