comparison src/dnsbl.cpp @ 293:fbbc341001cc

allow broken SRS0+ rather than the correct SRS0= tag
author Carl Byington <carl@five-ten-sg.com>
date Fri, 18 Jul 2014 15:01:27 -0700
parents 9f0d9fcb58dd
children 05b604c99e06
comparison
equal deleted inserted replaced
292:fa657d8a56d1 293:fbbc341001cc
1104 char *key = strdup(email); 1104 char *key = strdup(email);
1105 key[n] = '\0'; 1105 key[n] = '\0';
1106 for (int i=0; i<n; i++) key[i] = tolower(key[i]); 1106 for (int i=0; i<n; i++) key[i] = tolower(key[i]);
1107 if ((n > 14) && (strncmp(key, "srs", 3) == 0)) { 1107 if ((n > 14) && (strncmp(key, "srs", 3) == 0)) {
1108 // might have srs coding to be removed 1108 // might have srs coding to be removed
1109 const int nmatch = 6; 1109 const int nmatch = 7;
1110 regmatch_t match[nmatch]; 1110 regmatch_t match[nmatch];
1111 if (0 == regexec(&srs_pattern, key, nmatch, match, 0)) { 1111 if (0 == regexec(&srs_pattern, key, nmatch, match, 0)) {
1112 int s4 = match[4].rm_so; // domain 1112 int s4 = match[5].rm_so; // domain
1113 int e4 = match[4].rm_eo; 1113 int e4 = match[5].rm_eo;
1114 int s5 = match[5].rm_so; // user 1114 int s5 = match[6].rm_so; // user
1115 int e5 = match[5].rm_eo; 1115 int e5 = match[6].rm_eo;
1116 if ((s4 != -1) && (s5 != -1)) { 1116 if ((s4 != -1) && (s5 != -1)) {
1117 char *newkey = strdup(key); // large enough 1117 char *newkey = strdup(key); // large enough
1118 key[e4] = '\0'; 1118 key[e4] = '\0';
1119 key[e5] = '\0'; 1119 key[e5] = '\0';
1120 strcpy(newkey, key+s5); // user 1120 strcpy(newkey, key+s5); // user
1769 int c; 1769 int c;
1770 const char *args = "b:r:p:t:e:d:chs"; 1770 const char *args = "b:r:p:t:e:d:chs";
1771 extern char *optarg; 1771 extern char *optarg;
1772 1772
1773 // setup srs coding detection 1773 // setup srs coding detection
1774 if (regcomp(&srs_pattern, "^srs(0|1)=([^=]+)=([^=]+)=([^=]+)=([^@]+)@", REG_ICASE | REG_EXTENDED)) { 1774 if (regcomp(&srs_pattern, "^srs(0|1)(=|\+)([^=]+)=([^=]+)=([^=]+)=([^@]+)@", REG_ICASE | REG_EXTENDED)) {
1775 printf("cannot compile regex pattern to find srs coding in mail addresses\n"); 1775 printf("cannot compile regex pattern to find srs coding in mail addresses\n");
1776 exit(3); 1776 exit(3);
1777 } 1777 }
1778 1778
1779 // setup prvs coding detection 1779 // setup prvs coding detection