comparison src/scanner.cpp @ 130:e316f6fd9c39

uribl lookups fully qualified; allow two component host names
author carl
date Tue, 01 Aug 2006 10:44:55 -0700
parents d9d2f8699621
children df355d117199
comparison
equal deleted inserted replaced
129:c5cd1261394d 130:e316f6fd9c39
1201 if (next2) next2->push(pending, count); 1201 if (next2) next2->push(pending, count);
1202 count = 0; 1202 count = 0;
1203 } 1203 }
1204 1204
1205 void fsa::validhost () { 1205 void fsa::validhost () {
1206 // remove trailing dot 1206 // remove trailing periods
1207 if (pending[count-1]== '.') pending[--count] = '\0'; 1207 while (count && (pending[count-1]== '.')) pending[--count] = '\0';
1208 if (!count) return; // empty string
1208 if (!strchr((const char *)pending, '@')) { 1209 if (!strchr((const char *)pending, '@')) {
1209 // not an email address or message id 1210 // not an email address or message id
1210 char *p1 = strchr((const char *)pending, '.'); 1211 char *p1 = strchr((const char *)pending, '.');
1211 char *p2 = strrchr((const char *)pending, '.'); 1212 char *p2 = strrchr((const char *)pending, '.');
1212 char *p3 = strstr((const char *)pending, ".."); 1213 char *p3 = strstr((const char *)pending, "..");
1213 if (p1 && (p1 != p2) & !p3) { 1214 if (p1 && (p1 != pending) & !p3) {
1214 // have two periods, so at least three components, and no empty components 1215 // have a period, so at least two components, and no empty components
1215 in_addr ip; 1216 in_addr ip;
1216 if (inet_aton((const char*)pending, &ip)) 1217 if (inet_aton((const char*)pending, &ip))
1217 memory->new_url((char*)pending); 1218 memory->new_url((char*)pending);
1218 else { 1219 else {
1219 for (int i=0; i<count; i++) pending[i] = tolower(pending[i]); 1220 for (int i=0; i<count; i++) pending[i] = tolower(pending[i]);