Skip to content

Commit

Permalink
🚨 SASL: add_authenticator warns on reassignment (🚧 ???)
Browse files Browse the repository at this point in the history
The question is: do we even want to this?
  • Loading branch information
nevans committed Nov 8, 2024
1 parent 212ef7a commit a1089f6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/net/imap/sasl/authenticators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def names; @authenticators.keys end
# When only a single argument is given, the authenticator class will be
# lazily loaded from <tt>Net::IMAP::SASL::#{name}Authenticator</tt> (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
Expand All @@ -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

Expand Down

0 comments on commit a1089f6

Please sign in to comment.