From eae8e04ee933c8bf1d48387d301f4bdd8737259d Mon Sep 17 00:00:00 2001 From: nick evans Date: Tue, 13 Jun 2023 18:25:52 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20SASL:=20add=5Fauthenticator=20wa?= =?UTF-8?q?rns=20on=20reassignment=20(=F0=9F=9A=A7=20=3F=3F=3F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The question is: do we even want to this? --- lib/net/imap/sasl/authenticators.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/net/imap/sasl/authenticators.rb b/lib/net/imap/sasl/authenticators.rb index 4c26e452..5d28cc8e 100644 --- a/lib/net/imap/sasl/authenticators.rb +++ b/lib/net/imap/sasl/authenticators.rb @@ -68,7 +68,7 @@ def names; @authenticators.keys end # When only a single argument is given, the authenticator class will be # lazily loaded from Net::IMAP::SASL::#{name}Authenticator (case is # preserved and non-alphanumeric characters are removed.. - def add_authenticator(name, authenticator = nil) + def add_authenticator(name, authenticator = nil, warn_overwrite: true) authenticator ||= begin class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym auth_class = nil @@ -78,6 +78,11 @@ def add_authenticator(name, authenticator = nil) } end key = Authenticators.normalize_name(name) + if warn_overwrite && (original = @authenticators[key]) + warn("%p: replacing existing %p authenticator: %p" % [ + self, key, original + ], uplevel: 1) + end @authenticators[key] = authenticator end