if (getword(year,sizeof(year),&gwarea,'-')<0 || getword(mon,sizeof(mon),&gwarea,'-')<0 ||
getword(day,sizeof(day),&gwarea,' ')<0 || getword(hour,sizeof(hour),&gwarea,' ')<0 ||
getword_skip(MAXLEN,&gwarea,'/')<0 || getword(list,sizeof(list),&gwarea,'/')<0 ||
- getword_skip(MAXLEN,&gwarea,'/')<0 || getword_skip(MAXLEN,&gwarea,'/')<0 ||
- getword(url,sizeof(url),&gwarea,' ')<0 ||
+ getword_skip(MAXLEN,&gwarea,' ')<0 || getword(url,sizeof(url),&gwarea,' ')<0 ||
getword(ip,sizeof(ip),&gwarea,'/')<0 || getword_skip(MAXLEN,&gwarea,' ')<0 ||
getword(user,sizeof(user),&gwarea,' ')<0) {
printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wentp);
exit(1);
}
+ /*
+ The URL may be "http://url:port/data" if the method is GET or simply "url:port/" if the method is CONNECT.
+ The following code removes the protocol:// if it is detected and always truncates the URL after the domain name.
+ It will fail if the URL doesn't start with the protocol and contains two consecutive / in the path (i.e.
+ the URL is not normalized).
+ */
str=strchr(url,'/');
- if (str) *str='\0';
+ if (str) {
+ if (str[1]=='/') {
+ str+=2;
+ for (i=0 ; *str && *str!='/' ; i++) url[i]=*str++;
+ url[i]='\0';
+ } else {
+ *str='\0';
+ }
+ }
}
sprintf(warea,"%s%s%s",year,mon,day);
if (strcmp(user,"-") == 0) {
strcpy(user,ip);
- memset(ip,0,sizeof(ip));
+ ip[0]='\0';
}
fprintf(fp_ou,"%s\t%s%s%s\t%s\t%s\t%s\t%s\n",user,year,mon,day,hour,ip,url,list);
squidguard_count++;