summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-08 10:42:05 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-08 10:42:05 +0000
commitc705ba5a89cd7b5c19677f4950c9784828ffc5c6 (patch)
tree9ae09e5feb716b4ed288bd29830a3daf4c0393f7 /lib
parentd9e9ad0dec4695bae68543cf89768da6f2b905f8 (diff)
Previous attempt at cleaning up the prefix matcher were too restrictive, try using a different approach
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/irc.rb20
-rw-r--r--lib/rbot/rfc2812.rb4
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb
index a07c8b23..c2c1e82f 100644
--- a/lib/rbot/irc.rb
+++ b/lib/rbot/irc.rb
@@ -554,12 +554,18 @@ class Regexp
# User-matching Regexp
GEN_USER_ID = /(#{GEN_NICK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/
- # For Netmask, we want to allow wildcards * and ? in the nick
- # (they are already allowed in the user and host part
- GEN_NICK_MASK = /(?:#{NICK_FIRST}|[?*])?(?:#{NICK_ANY}|[?*])+/
+ # Things such has the BIP proxy send invalid nicks in a complete netmask,
+ # so we want to match this, rather: this matches either a compliant nick
+ # or a a string with a very generic nick, a very generic hostname after an
+ # @ sign, and an optional user after a !
+ BANG_AT = /#{GEN_NICK}|\S+?(?:!\S+?)?@\S+?/
- # Netmask-matching Regexp
- GEN_MASK = /(#{GEN_NICK_MASK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/
+ # # For Netmask, we want to allow wildcards * and ? in the nick
+ # # (they are already allowed in the user and host part
+ # GEN_NICK_MASK = /(?:#{NICK_FIRST}|[?*])?(?:#{NICK_ANY}|[?*])+/
+
+ # # Netmask-matching Regexp
+ # GEN_MASK = /(#{GEN_NICK_MASK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/
end
@@ -608,7 +614,9 @@ module Irc
# Now we can see if the given string _str_ is an actual Netmask
if str.respond_to?(:to_str)
case str.to_str
- when /^(?:#{Regexp::Irc::GEN_MASK})?$/
+ # We match a pretty generic string, to work around non-compliant
+ # servers
+ when /^(?:(\S+?)(?:(?:!(\S+?))?@(\S+))?)?$/
# We do assignment using our internal methods
self.nick = $1
self.user = $2
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb
index 1ab981f8..482cefe7 100644
--- a/lib/rbot/rfc2812.rb
+++ b/lib/rbot/rfc2812.rb
@@ -902,12 +902,12 @@ module Irc
# This is not always true, though, since some servers do not send a
# full hostmask for user messages.
#
- if prefix =~ /^#{Regexp::Irc::GEN_USER_ID}$/
+ if prefix =~ /^#{Regexp::Irc::BANG_AT}$/
data[:source] = @server.user(prefix)
else
if @server.hostname
if @server.hostname != prefix
- # TODO do we want to be able to differentiated messages that are passed on to us from /other/ servers?
+ # TODO do we want to be able to differentiate messages that are passed on to us from /other/ servers?
debug "Origin #{prefix} for message\n\t#{serverstring.inspect}\nis neither a user hostmask nor the server hostname\nI'll pretend that it's from the server anyway"
data[:source] = @server
else