]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Previous attempt at cleaning up the prefix matcher were too restrictive, try using...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 8 Mar 2007 10:42:05 +0000 (10:42 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 8 Mar 2007 10:42:05 +0000 (10:42 +0000)
lib/rbot/irc.rb
lib/rbot/rfc2812.rb

index a07c8b230a8156a241cedb6709478fadb1003f04..c2c1e82fdd518c30889a1eed9cad0830857ea9de 100644 (file)
@@ -554,12 +554,18 @@ class Regexp
     # 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
+    # Things such has the BIP proxy send invalid nicks in a complete netmask,\r
+    # so we want to match this, rather: this matches either a compliant nick\r
+    # or a a string with a very generic nick, a very generic hostname after an\r
+    # @ sign, and an optional user after a !\r
+    BANG_AT = /#{GEN_NICK}|\S+?(?:!\S+?)?@\S+?/\r
 \r
-    # Netmask-matching Regexp\r
-    GEN_MASK = /(#{GEN_NICK_MASK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/\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_MASK})(?:(?:!(#{GEN_USER}))?@(#{GEN_HOST_EXT}))?/\r
 \r
   end\r
 \r
@@ -608,7 +614,9 @@ module Irc
       # Now we can see if the given string _str_ is an actual Netmask\r
       if str.respond_to?(:to_str)\r
         case str.to_str\r
-        when /^(?:#{Regexp::Irc::GEN_MASK})?$/\r
+          # We match a pretty generic string, to work around non-compliant\r
+          # servers\r
+        when /^(?:(\S+?)(?:(?:!(\S+?))?@(\S+))?)?$/\r
           # We do assignment using our internal methods\r
           self.nick = $1\r
           self.user = $2\r
index 1ab981f8111909807c3457d1eff9ac7397e02486..482cefe7a2c51962df5d18bdab87f4b641cb95b9 100644 (file)
@@ -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