diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-10-17 14:17:00 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-10-17 14:17:00 +0300 |
commit | b441439d550de340e892903b1309fb35bfba6312 (patch) | |
tree | e375e802f6a1173abe9dd29053e1e5ff2aae4123 /src/lua | |
parent | 350af45ecb3cdd4fc08989ee5365f8e9a5044e83 (diff) | |
download | rspamd-b441439d550de340e892903b1309fb35bfba6312.tar.gz rspamd-b441439d550de340e892903b1309fb35bfba6312.zip |
Check utf8 characters before gregex checks as they assume input to be a utf8 valid string.
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_regexp.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c index 100b106fe..ba9a4dabc 100644 --- a/src/lua/lua_regexp.c +++ b/src/lua/lua_regexp.c @@ -160,6 +160,13 @@ lua_regexp_match (lua_State *L) if (re) { data = luaL_checkstring (L, 2); if (data) { + if ((g_regex_get_compile_flags (re) & G_REGEX_RAW) == 0) { + /* Validate input */ + if (!g_utf8_validate (data, -1, NULL)) { + lua_pushnil (L); + return 1; + } + } if (g_regex_match_full (re, data, -1, 0, 0, &mi, NULL)) { matches = g_match_info_fetch_all (mi); lua_newtable (L); |