diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-03-05 21:59:51 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-03-05 21:59:51 +0000 |
commit | 90671f2fe2dded0e1423dee33d073c6531b02b41 (patch) | |
tree | 7e15f178c0c0edd0cddada086a4ee125b48f5139 | |
parent | d8a22eb45b2fd816319a58786d18cf00b4b16031 (diff) |
Previous commit wasn't that good, too restrictive. Relax, and differentiate between user id and mask
-rw-r--r-- | lib/rbot/irc.rb | 37 | ||||
-rw-r--r-- | lib/rbot/rfc2812.rb | 2 |
2 files changed, 27 insertions, 12 deletions
diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 1c9d4dcd..a07c8b23 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -533,19 +533,34 @@ class Regexp GEN_HOST = /#{HOSTNAME}|#{HOSTADDR}/
- # FreeNode network replaces the host of affiliated users with
- # 'virtual hosts'
- # FIXME we need the true syntax to match it properly ...
- PDPC_HOST_PART = /[0-9A-Za-z.-]+/
- PDPC_HOST = /#{PDPC_HOST_PART}(?:\/#{PDPC_HOST_PART})+/
-
- # NOTE: the final optional and non-greedy dot is needed because some
- # servers (e.g. FreeNode) send the hostname of the services as "services."
- # which is not RFC compliant, but sadly done.
- GEN_MASK_HOST = /#{PDPC_HOST}|#{GEN_HOST}\.??/
+ # # FreeNode network replaces the host of affiliated users with
+ # # 'virtual hosts'
+ # # FIXME we need the true syntax to match it properly ...
+ # PDPC_HOST_PART = /[0-9A-Za-z.-]+/
+ # PDPC_HOST = /#{PDPC_HOST_PART}(?:\/#{PDPC_HOST_PART})+/
+
+ # # NOTE: the final optional and non-greedy dot is needed because some
+ # # servers (e.g. FreeNode) send the hostname of the services as "services."
+ # # which is not RFC compliant, but sadly done.
+ # GEN_HOST_EXT = /#{PDPC_HOST}|#{GEN_HOST}\.??/
+
+ # Sadly, different networks have different, RFC-breaking ways of cloaking
+ # the actualy host address: see above for an example to handle FreeNode.
+ # Another example would be Azzurra, wich also inserts a "=" in the
+ # cloacked host. So let's just not care about this and go with the simplest
+ # thing:
+ GEN_HOST_EXT = /\S+/
+
+ # 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}|[?*])+/
# Netmask-matching Regexp
- GEN_MASK = /(#{GEN_NICK})(?:(?:!(#{GEN_USER}))?@(#{GEN_MASK_HOST}))?/
+ GEN_MASK = /(#{GEN_NICK_MASK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/
+
end
end
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index efa50035..1ab981f8 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -902,7 +902,7 @@ 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_MASK}$/ + if prefix =~ /^#{Regexp::Irc::GEN_USER_ID}$/ data[:source] = @server.user(prefix) else if @server.hostname |