comparison src/dnsbl.cpp @ 127:2b1a4701e856

sendmail no longer guarantees <> wrapper on envelopes
author carl
date Sat, 08 Apr 2006 10:06:09 -0700
parents 05ae49d37896
children 9ab51896447f
comparison
equal deleted inserted replaced
126:05ae49d37896 127:2b1a4701e856
852 } 852 }
853 } 853 }
854 return false; 854 return false;
855 } 855 }
856 856
857 //////////////////////////////////////////////// 857
858 // this email address is passed in from sendmail, and will 858 ////////////////////////////////////////////////
859 // always be enclosed in <>. It may have mixed case, just 859 //
860 // as the mail client sent it. We dup the string and convert 860 // this email address is passed in from sendmail, and will normally be
861 // the duplicate to lower case. 861 // enclosed in <>. I think older versions of sendmail supplied the <>
862 // wrapper if the mail client did not, but the current version does not do
863 // that. So the <> wrapper is now optional. It may have mixed case, just
864 // as the mail client sent it. We dup the string and convert the duplicate
865 // to lower case.
862 // 866 //
863 char *to_lower_string(char *email); 867 char *to_lower_string(char *email);
864 char *to_lower_string(char *email) { 868 char *to_lower_string(char *email) {
865 int n = strlen(email)-2; 869 int n = strlen(email);
866 if (n < 1) return strdup(email); 870 if (*email == '<') {
867 char *key = strdup(email+1); 871 // assume it also ends with >
872 n -= 2;
873 if (n < 1) return strdup(email); // return "<>"
874 email++;
875 }
876 char *key = strdup(email);
868 key[n] = '\0'; 877 key[n] = '\0';
869 for (int i=0; i<n; i++) key[i] = tolower(key[i]); 878 for (int i=0; i<n; i++) key[i] = tolower(key[i]);
870 return key; 879 return key;
871 } 880 }
872 881