From b398b46b1ae895fd0b3fbfdc6c4aec753639be1b 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 f5daa5ec..cf6e3b40 100644 --- a/lib/net/imap/sasl/authenticators.rb +++ b/lib/net/imap/sasl/authenticators.rb @@ -64,7 +64,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) key = -name.to_s.upcase.tr(?_, ?-) authenticator ||= begin class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym @@ -74,6 +74,11 @@ def add_authenticator(name, authenticator = nil) auth_class.new(*creds, **props, &block) } end + if warn_overwrite && (original = @authenticators[key]) + warn("%p: replacing existing %p authenticator: %p" % [ + self, key, original + ], uplevel: 1) + end @authenticators[key] = authenticator end