aboutsummaryrefslogtreecommitdiffstats
path: root/src/ragel
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-21 08:59:05 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-21 08:59:05 +0100
commitfa4f75e41ebcbf9a45c0077ca040db3df9dc0936 (patch)
tree888b345f38d1aeccdc816b432c467c9c0be9fd5a /src/ragel
parent22794d547d1147d31bb226912ea37bfc8bf8d5f1 (diff)
downloadrspamd-fa4f75e41ebcbf9a45c0077ca040db3df9dc0936.tar.gz
rspamd-fa4f75e41ebcbf9a45c0077ca040db3df9dc0936.zip
[Feature] Rework newlines strip parser one more time
Issue: #1687
Diffstat (limited to 'src/ragel')
-rw-r--r--src/ragel/newlines_strip.rl82
1 files changed, 0 insertions, 82 deletions
diff --git a/src/ragel/newlines_strip.rl b/src/ragel/newlines_strip.rl
deleted file mode 100644
index d5de198a5..000000000
--- a/src/ragel/newlines_strip.rl
+++ /dev/null
@@ -1,82 +0,0 @@
-%%{
- machine newlines_strip;
-
- action Double_CRLF {
- if (!crlf_added && p > c) {
- (*newlines_count)++;
- g_byte_array_append (data, (const guint8 *)" ", 1);
- c = p;
- }
-
- crlf_added = TRUE;
- c = p;
- }
-
- action WSP {
- g_byte_array_append (data, (const guint8 *)" ", 1);
- c = p;
- }
-
- action Text_Start {
- crlf_added = FALSE;
- c = p;
- }
-
- action Text_End {
- if (p > c) {
- g_byte_array_append (data, (const guint8 *)c, p - c);
- last_c = *(p - 1);
- }
-
- c = p;
- }
-
- action Line_CRLF {
- if (!crlf_added) {
- if (is_html || g_ascii_ispunct (last_c)) {
- g_byte_array_append (data, (const guint8 *)" ", 1);
- crlf_added = TRUE;
- }
- }
-
- (*newlines_count)++;
- g_ptr_array_add (newlines, (((gpointer) (goffset) (data->len))));
- c = p;
- }
-
-
- WSP = " " | "\t" | "\v";
- CRLF = ("\r" . "\n") | ( "\r" ) | ("\n");
- DOUBLE_CRLF = (CRLF <: (WSP* CRLF)+) %Double_CRLF;
- ANY_CRLF = CRLF | DOUBLE_CRLF;
- LINE = (([^\r\n]+) >Text_Start %Text_End);
- TEXT = ANY_CRLF* . (LINE <: ANY_CRLF %Line_CRLF)+ | LINE | ANY_CRLF %Line_CRLF;
-
- main := TEXT;
-}%%
-
-#include <glib.h>
-
-%% write data;
-
-void
-rspamd_strip_newlines_parse (const gchar *begin, const gchar *pe,
- GByteArray *data, gboolean is_html, guint *newlines_count,
- GPtrArray *newlines)
-{
- const gchar *c, *p, *eof;
- gint last_c = -1;
- gint cs = 0;
- gboolean crlf_added = FALSE;
-
- c = begin;
- p = begin;
- eof = pe;
-
- %% write init;
- %% write exec;
-
- if (p > c) {
- g_byte_array_append (data, (const guint8 *)c, p - c);
- }
-}