From de7fea53e0671ab24073331f9a0600be1d9f81d5 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 88d5feb5..2abf2626 100644 --- a/lib/net/imap/sasl/authenticators.rb +++ b/lib/net/imap/sasl/authenticators.rb @@ -65,7 +65,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.upcase.to_sym authenticator ||= begin class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym @@ -75,6 +75,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