]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix splitting in case of bogus regexp.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 14 Jul 2015 12:56:05 +0000 (13:56 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 14 Jul 2015 12:56:05 +0000 (13:56 +0100)
src/lua/lua_regexp.c
test/lua/unit/regxep.lua

index 2f7ea3ea16b876f8b0dc252130376cd93174ca0f..75e54bab5c0aec00ab550f25c6748be4bd9f3c37 100644 (file)
@@ -568,6 +568,9 @@ lua_regexp_split (lua_State *L)
                                        lua_rawseti (L, -2, ++i);
                                        matched = TRUE;
                                }
+                               else if (start == end) {
+                                       break;
+                               }
                                old_start = end;
                        }
 
index d0b1c422fa06ac8d7747e7c85c9742cda170bcbb..0bb4db9351df235fed00a24f04cb210e16fee650 100644 (file)
@@ -68,6 +68,9 @@ context("Regexp unit tests", function()
       {'\\s', '  one   two  ', {'one', 'two'}}, -- multiple delimiters
       {'\\s', '  one   ', {'one'}}, -- multiple delimiters
       {'[:,]', ',,,:::one,two,,', {'one', 'two'}}, -- multiple delimiters
+      {'[\\|\\s]', '16265 | 1.1.1.0/22 | TR | ripencc | 2014-02-28', 
+        {'16265', '1.1.1.0/22', 'TR', 'ripencc', '2014-02-28'}}, -- practical
+      {'|', '16265 | 1.1.1.0/22 | TR | ripencc | 2014-02-28', {}} -- bad re
     }
   
     for _,c in ipairs(cases) do