]> source.dussan.org Git - rspamd.git/commitdiff
Fix match behaviour.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 4 Mar 2015 16:00:55 +0000 (16:00 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 4 Mar 2015 16:00:55 +0000 (16:00 +0000)
src/lua/lua_regexp.c

index 04f141fb33adb9f67db29d99b2d98c3f9d7f298b..84455280f04f7193a10bc51042fd90e2c7621dc8 100644 (file)
@@ -123,14 +123,23 @@ lua_regexp_create (lua_State *L)
                }
        }
        else if (string[0] == 'm') {
-               /* Special case for perl */
+               /* Special case for m */
                slash = &string[1];
                sep = *slash;
-               slash = strrchr (string, sep);
-               if (slash != NULL && slash > &string[1]) {
-                       flags_str = slash + 1;
-                       pattern = g_malloc (slash - string - 1);
-                       rspamd_strlcpy (pattern, string + 2, slash - string - 1);
+
+               if (sep == '\0' || g_ascii_isalnum (sep)) {
+                       /* Not a special case */
+               }
+               else {
+                       slash = strrchr (string, sep);
+                       if (slash != NULL && slash > &string[1]) {
+                               flags_str = slash + 1;
+                               pattern = g_malloc (slash - string + 1);
+                               pattern[0] = '^';
+                               rspamd_strlcpy (pattern + 1, string + 2, slash - string - 1);
+                               pattern[slash - string - 1] = '$';
+                               pattern[slash - string] = '\0';
+                       }
                }
        }
        else {