]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Previous commit wasn't that good, too restrictive. Relax, and differentiate between...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 5 Mar 2007 21:59:51 +0000 (21:59 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 5 Mar 2007 21:59:51 +0000 (21:59 +0000)
lib/rbot/irc.rb
lib/rbot/rfc2812.rb

index 1c9d4dcd5a9186054aa0a8ecbe81c080860ff84f..a07c8b230a8156a241cedb6709478fadb1003f04 100644 (file)
@@ -533,19 +533,34 @@ class Regexp
 \r
     GEN_HOST = /#{HOSTNAME}|#{HOSTADDR}/\r
 \r
-    # FreeNode network replaces the host of affiliated users with\r
-    # 'virtual hosts' \r
-    # FIXME we need the true syntax to match it properly ...\r
-    PDPC_HOST_PART = /[0-9A-Za-z.-]+/\r
-    PDPC_HOST = /#{PDPC_HOST_PART}(?:\/#{PDPC_HOST_PART})+/\r
-\r
-    # NOTE: the final optional and non-greedy dot is needed because some\r
-    # servers (e.g. FreeNode) send the hostname of the services as "services."\r
-    # which is not RFC compliant, but sadly done.\r
-    GEN_MASK_HOST = /#{PDPC_HOST}|#{GEN_HOST}\.??/ \r
+    # # FreeNode network replaces the host of affiliated users with\r
+    # # 'virtual hosts' \r
+    # # FIXME we need the true syntax to match it properly ...\r
+    # PDPC_HOST_PART = /[0-9A-Za-z.-]+/\r
+    # PDPC_HOST = /#{PDPC_HOST_PART}(?:\/#{PDPC_HOST_PART})+/\r
+\r
+    # # NOTE: the final optional and non-greedy dot is needed because some\r
+    # # servers (e.g. FreeNode) send the hostname of the services as "services."\r
+    # # which is not RFC compliant, but sadly done.\r
+    # GEN_HOST_EXT = /#{PDPC_HOST}|#{GEN_HOST}\.??/ \r
+\r
+    # Sadly, different networks have different, RFC-breaking ways of cloaking\r
+    # the actualy host address: see above for an example to handle FreeNode.\r
+    # Another example would be Azzurra, wich also inserts a "=" in the\r
+    # cloacked host. So let's just not care about this and go with the simplest\r
+    # thing:\r
+    GEN_HOST_EXT = /\S+/\r
+\r
+    # User-matching Regexp\r
+    GEN_USER_ID = /(#{GEN_NICK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/\r
+\r
+    # For Netmask, we want to allow wildcards * and ? in the nick\r
+    # (they are already allowed in the user and host part\r
+    GEN_NICK_MASK = /(?:#{NICK_FIRST}|[?*])?(?:#{NICK_ANY}|[?*])+/\r
 \r
     # Netmask-matching Regexp\r
-    GEN_MASK = /(#{GEN_NICK})(?:(?:!(#{GEN_USER}))?@(#{GEN_MASK_HOST}))?/\r
+    GEN_MASK = /(#{GEN_NICK_MASK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/\r
+\r
   end\r
 \r
 end\r
index efa50035f87af634ca71007e24241c69aa9ca87a..1ab981f8111909807c3457d1eff9ac7397e02486 100644 (file)
@@ -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