gpointer ud;
gpointer re_class;
guint64 cache_id;
+ gsize match_limit;
guint max_hits;
gint flags;
gint pcre_flags;
len = strlen (text);
}
+ if (re->match_limit > 0 && len > re->match_limit) {
+ len = re->match_limit;
+ }
+
if (end != NULL && *end != NULL) {
/* Incremental search */
mt = (*end);
return old;
}
+gsize
+rspamd_regexp_get_match_limit (const rspamd_regexp_t *re)
+{
+ g_assert (re != NULL);
+
+ return re->match_limit;
+}
+
+gsize
+rspamd_regexp_set_match_limit (rspamd_regexp_t *re, gsize lim)
+{
+ gsize old;
+
+ g_assert (re != NULL);
+ old = re->match_limit;
+ re->match_limit = lim;
+
+ return old;
+}
+
gboolean
rspamd_regexp_match (const rspamd_regexp_t *re, const gchar *text, gsize len,
gboolean raw)
*/
guint64 rspamd_regexp_set_cache_id (rspamd_regexp_t *re, guint64 id);
+/**
+ * Returns match limit for a regexp
+ */
+gsize rspamd_regexp_get_match_limit (const rspamd_regexp_t *re);
+
+/**
+ * Sets cache id for a regexp
+ */
+gsize rspamd_regexp_set_match_limit (rspamd_regexp_t *re, gsize lim);
+
/**
* Get regexp class for the re object
*/
if (re && re->re && !IS_DESTROYED (re)) {
if (lim > 0) {
- re->match_limit = lim;
+ rspamd_regexp_set_match_limit(re->re, lim);
}
else {
- re->match_limit = 0;
+ rspamd_regexp_set_match_limit(re->re, 0);
}
}
lua_newtable (L);
i = 0;
- if (re->match_limit > 0) {
- len = MIN (len, re->match_limit);
- }
-
while (rspamd_regexp_search (re->re, data, len, &start, &end, raw,
captures)) {
}
if (data && len > 0) {
- if (re->match_limit > 0) {
- len = MIN (len, re->match_limit);
- }
-
if (rspamd_regexp_search (re->re, data, len, NULL, NULL, raw, NULL)) {
lua_pushboolean (L, TRUE);
}
}
if (data && len > 0) {
-
- if (re->match_limit > 0) {
- len = MIN (len, re->match_limit);
- }
-
for (;;) {
if (rspamd_regexp_search (re->re, data, len, &start, &end, raw,
NULL)) {
is_text = TRUE;
}
- if (re->match_limit > 0) {
- len = MIN (len, re->match_limit);
- }
-
if (data && len > 0) {
lua_newtable (L);
i = 0;