mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-12 23:17:02 +02:00
added a few unit tests
This commit is contained in:
@ -679,7 +679,7 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
|
||||
|
||||
strncat(puf, " ", sizeof(puf)-1);
|
||||
|
||||
if(strncasecmp(puf, "http://", 7) == 0 || strncasecmp(puf, "https://", 8) == 0) fixURL(puf);
|
||||
if(strncasecmp(puf, "http://", 7) == 0 || strncasecmp(puf, "https://", 8) == 0) fixURL(puf, sizeof(puf)-1);
|
||||
|
||||
if(state->is_header == 0 && strncmp(puf, "__URL__", 7) && (puf[0] == ' ' || (strlen(puf) > MAX_WORD_LEN && cfg->enable_cjk == 0) || isHexNumber(puf)) ) continue;
|
||||
|
||||
|
@ -28,8 +28,8 @@ void split_email_address(char *s);
|
||||
int does_it_seem_like_an_email_address(char *email);
|
||||
void reassembleToken(char *p);
|
||||
void degenerateToken(unsigned char *p);
|
||||
void fixURL(char *url);
|
||||
int extractNameFromHeaderLine(char *s, char *name, char *resultbuf);
|
||||
void fixURL(char *buf, int buflen);
|
||||
void extractNameFromHeaderLine(char *s, char *name, char *resultbuf);
|
||||
char *determine_attachment_type(char *filename, char *type);
|
||||
char *get_attachment_extractor_by_filename(char *filename);
|
||||
void parse_reference(struct parser_state *state, char *s);
|
||||
|
@ -723,18 +723,18 @@ void degenerateToken(unsigned char *p){
|
||||
}
|
||||
|
||||
|
||||
void fixURL(char *url){
|
||||
void fixURL(char *buf, int buflen){
|
||||
int len=0;
|
||||
char *p, *q, fixed_url[SMALLBUFSIZE];
|
||||
|
||||
if(strlen(url) < 3) return;
|
||||
if(strlen(buf) < 3) return;
|
||||
|
||||
memset(fixed_url, 0, sizeof(fixed_url));
|
||||
|
||||
p = url;
|
||||
p = buf;
|
||||
|
||||
if(strncasecmp(url, "http://", 7) == 0) p += 7;
|
||||
if(strncasecmp(url, "https://", 8) == 0) p += 8;
|
||||
if(strncasecmp(buf, "http://", 7) == 0) p += 7;
|
||||
if(strncasecmp(buf, "https://", 8) == 0) p += 8;
|
||||
|
||||
q = strchr(p, '/');
|
||||
if(q) *q = '\0';
|
||||
@ -748,12 +748,12 @@ void fixURL(char *url){
|
||||
fixed_url[len-1] = '\0';
|
||||
}
|
||||
|
||||
strcpy(url, fixed_url);
|
||||
snprintf(buf, buflen, "%s", fixed_url);
|
||||
}
|
||||
|
||||
|
||||
int extractNameFromHeaderLine(char *s, char *name, char *resultbuf){
|
||||
int rc=0, extended=0;
|
||||
void extractNameFromHeaderLine(char *s, char *name, char *resultbuf){
|
||||
int extended=0;
|
||||
char buf[SMALLBUFSIZE], puf[SMALLBUFSIZE], *p, *q, *encoding;
|
||||
|
||||
snprintf(buf, sizeof(buf)-1, "%s", s);
|
||||
@ -826,11 +826,9 @@ int extractNameFromHeaderLine(char *s, char *name, char *resultbuf){
|
||||
snprintf(resultbuf, TINYBUFSIZE-1, "%s", puf);
|
||||
}
|
||||
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user