]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_links.c
Allow /ojoin !#channel/%#channel, if admin/halfop are enabled.
[irc/rqf/shadowircd.git] / modules / m_links.c
index f68d19a7aa49ce1029890b74f28f4586fd9542c0..bc28ad8bc17b22f60be453a76ed757a942091ac9 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "stdinc.h"
 #include "client.h"
-#include "irc_string.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "s_serv.h"
@@ -40,6 +40,7 @@
 
 static int m_links(struct Client *, struct Client *, int, const char **);
 static int mo_links(struct Client *, struct Client *, int, const char **);
+static char * clean_string(char *dest, const unsigned char *src, size_t len);
 
 struct Message links_msgtab = {
        "LINKS", 0, 0, 0, MFLG_SLOW,
@@ -58,10 +59,8 @@ DECLARE_MODULE_AV1(links, NULL, NULL, links_clist, links_hlist, NULL, "$Revision
 
 /*
  * m_links - LINKS message handler
- *      parv[0] = sender prefix
  *      parv[1] = servername mask
  * or
- *      parv[0] = sender prefix
  *      parv[1] = server to query 
  *      parv[2] = servername mask
  */
@@ -88,6 +87,8 @@ mo_links(struct Client *client_p, struct Client *source_p, int parc, const char
 
        if(parc > 2)
        {
+               if(strlen(parv[2]) > HOSTLEN)
+                       return 0;
                if(hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, parc, parv)
                   != HUNTED_ISME)
                        return 0;
@@ -129,3 +130,38 @@ mo_links(struct Client *client_p, struct Client *source_p, int parc, const char
        return 0;
 }
 
+static char *
+clean_string(char *dest, const unsigned char *src, size_t len)
+{
+       char *d = dest;
+       s_assert(0 != dest);
+       s_assert(0 != src);
+
+       if(dest == NULL || src == NULL)
+               return NULL;
+
+       while (*src && (len > 1))
+       {
+               if(*src & 0x80) /* if high bit is set */
+               {
+                       *d++ = '.';
+                       --len;
+                       if(len <= 1)
+                               break;
+               }
+               else if(!IsPrint(*src)) /* if NOT printable */
+               {
+                       *d++ = '^';
+                       --len;
+                       if(len <= 1)
+                               break;
+                       *d++ = 0x40 + *src;     /* turn it into a printable */
+               }
+               else
+                       *d++ = *src;
+               ++src;
+               --len;
+       }
+       *d = '\0';
+       return dest;
+}