]> source.dussan.org Git - rspamd.git/commitdiff
Add compatibility layer with old spamc.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 5 Apr 2014 23:45:06 +0000 (16:45 -0700)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 5 Apr 2014 23:45:06 +0000 (16:45 -0700)
contrib/http-parser/http_parser.c
contrib/http-parser/http_parser.h

index 298eb28ea090cfb4226950df97e465faf1b80d07..9aef5c18571ef7750814cd97299ec6e66810c98e 100644 (file)
@@ -272,6 +272,8 @@ enum state
   , s_req_http_major
   , s_req_first_http_minor
   , s_req_http_minor
+  , s_req_spamc_start
+  , s_req_spamc
   , s_req_line_almost_done
 
   , s_header_field_start
@@ -925,7 +927,7 @@ size_t http_parser_execute (http_parser *parser,
             /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */
             break;
           case 'R': parser->method = HTTP_REPORT; break;
-          case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH */ break;
+          case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH or SYMBOLS */ break;
           case 'T': parser->method = HTTP_TRACE; break;
           case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break;
           default:
@@ -949,12 +951,18 @@ size_t http_parser_execute (http_parser *parser,
 
         matcher = method_strings[parser->method];
         if (ch == ' ' && matcher[parser->index] == '\0') {
-          parser->state = s_req_spaces_before_url;
+          if (parser->method != HTTP_SYMBOLS && parser->method != HTTP_CHECK) {
+            parser->state = s_req_spaces_before_url;
+          }
+          else {
+            parser->state = s_req_spamc_start;
+          }
         } else if (ch == matcher[parser->index]) {
           ; /* nada */
         } else if (parser->method == HTTP_CONNECT) {
           if (parser->index == 1 && ch == 'H') {
-            parser->method = HTTP_CHECKOUT;
+            /* XXX: CHECKOUT has been removed */
+            parser->method = HTTP_CHECK;
           } else if (parser->index == 2  && ch == 'P') {
             parser->method = HTTP_COPY;
           } else {
@@ -977,7 +985,10 @@ size_t http_parser_execute (http_parser *parser,
         } else if (parser->method == HTTP_SUBSCRIBE) {
           if (parser->index == 1 && ch == 'E') {
             parser->method = HTTP_SEARCH;
-          } else {
+          } else if (ch == 'Y') {
+            parser->method = HTTP_SYMBOLS;
+          }
+          else {
             SET_ERRNO(HPE_INVALID_METHOD);
             goto error;
           }
@@ -1204,6 +1215,29 @@ size_t http_parser_execute (http_parser *parser,
 
         break;
       }
+      case s_req_spamc_start:
+          switch (ch) {
+          case 'S':
+              parser->state = s_req_spamc;
+              break;
+          case ' ':
+              break;
+          default:
+             SET_ERRNO(HPE_INVALID_CONSTANT);
+             goto error;
+          }
+      break;
+
+      case s_req_spamc:
+      {
+          if (ch == CR) {
+            parser->state = s_req_line_almost_done;
+          }
+          else if (ch == LF) {
+            parser->state = s_header_field_start;
+          }
+          break;
+      }
 
       /* end of request line */
       case s_req_line_almost_done:
index 1a91c23f2b49fe23f56ce5d3dd8a5031f258c45a..a322634f1d4516b47108b3cec2c267d9c7333b1a 100644 (file)
@@ -110,6 +110,9 @@ typedef int (*http_cb) (http_parser*);
   /* RFC-5789 */                    \
   XX(24, PATCH,       PATCH)        \
   XX(25, PURGE,       PURGE)        \
+  /* SPAMC compatibility */                    \
+  XX(26, SYMBOLS,     SYMBOLS)      \
+  XX(27, CHECK,       CHECK)
 
 enum http_method
   {