From: Frédéric Marchal Date: Fri, 6 Jan 2012 13:08:58 +0000 (+0000) Subject: Fix the link to the URL in some reports X-Git-Tag: v2.3.3-pre1~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58c40ade99fffb2459e0525247d4570ca9ef3820;p=thirdparty%2Fsarg.git Fix the link to the URL in some reports Some URL are stripped of the scheme while others are not. Yet they were all printed using the same function that prefixed a http:// in front of the URL even if the original scheme was stil present. To make the links clickable without error in the report, the scheme may be provided by the caller when it requests the printing of the URL in a HTTM link. The affected reports were the authentication failures, the denied accesses and the downloaded files. Thanks to budsz for reporting this problem. --- diff --git a/authfail.c b/authfail.c index 8e74f78..fd3d99d 100644 --- a/authfail.c +++ b/authfail.c @@ -189,7 +189,7 @@ void authfail_report(void) output_html_url(fp_ou,url); fputs("\"> ",fp_ou); } - output_html_link(fp_ou,url,100); + output_html_link(fp_ou,"",url,100); //the original scheme is left in the URL fputs("\n",fp_ou); } fclose(fp_in); diff --git a/dansguardian_report.c b/dansguardian_report.c index 0bf7b48..93b80d7 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -155,7 +155,7 @@ void dansguardian_report(void) } fprintf(fp_ou,"%s%s%s-%s",name,ip,date,hour); - output_html_link(fp_ou,url,100); + output_html_link(fp_ou,NULL,url,100); fprintf(fp_ou,"%s\n",rule); } fclose(fp_in); diff --git a/denied.c b/denied.c index ec8505c..db49aa7 100644 --- a/denied.c +++ b/denied.c @@ -158,7 +158,7 @@ void gen_denied_report(void) output_html_url(fp_ou,url); fprintf(fp_ou,"\"> ",ImageFile); } - output_html_link(fp_ou,url,100); + output_html_link(fp_ou,"",url,100); //the URL contains the scheme fputs("\n",fp_ou); } fclose(fp_in); diff --git a/download.c b/download.c index 75421a6..51cb098 100644 --- a/download.c +++ b/download.c @@ -156,7 +156,7 @@ void download_report(void) output_html_url(fp_ou,url); fprintf(fp_ou,"\"> ",ImageFile); } - output_html_link(fp_ou,url,100); + output_html_link(fp_ou,"",url,100);//scheme is kept from the log file fputs("\n",fp_ou); } fclose(fp_in); diff --git a/html.c b/html.c index 84db764..b38d81e 100644 --- a/html.c +++ b/html.c @@ -285,7 +285,7 @@ void htmlrel(void) output_html_url(fp_ou,url); fprintf(fp_ou,"\"> ",tmp6); } - output_html_link(fp_ou,url,100); + output_html_link(fp_ou,NULL,url,100); fputs("",fp_ou); } diff --git a/include/defs.h b/include/defs.h index d24238d..403b335 100755 --- a/include/defs.h +++ b/include/defs.h @@ -253,7 +253,7 @@ void close_html_header(FILE *fp_ou); __attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou); void output_html_string(FILE *fp_ou,const char *str,int maxlen); void output_html_url(FILE *fp_ou,const char *url); -void output_html_link(FILE *fp_ou,const char *url,int maxlen); +void output_html_link(FILE *fp_ou,const char *scheme,const char *url,int maxlen); void debuga(const char *msg,...) __attribute__((format(printf,1,2))); void debugaz(const char *msg,...) __attribute__((format(printf,1,2))); void my_lltoa(unsigned long long int n, char *s, int ssize, int len); diff --git a/redirector.c b/redirector.c index b8ab00d..9e1ca67 100644 --- a/redirector.c +++ b/redirector.c @@ -552,7 +552,7 @@ void redirector_report(void) else fputs("",fp_ou); fprintf(fp_ou,"%s-%s",data,hora); - output_html_link(fp_ou,url,100); + output_html_link(fp_ou,NULL,url,100); fprintf(fp_ou,"%s\n",rule); } fclose(fp_in); diff --git a/siteuser.c b/siteuser.c index 997b271..a1c8743 100644 --- a/siteuser.c +++ b/siteuser.c @@ -146,7 +146,7 @@ void siteuser(void) output_html_url(fp_ou,ourl); fputs("\"> ",fp_ou); } - output_html_link(fp_ou,ourl,100); + output_html_link(fp_ou,NULL,ourl,100); fputs("",fp_ou); if (BytesInSitesUsersReport) { diff --git a/topsites.c b/topsites.c index e361331..9c05b21 100644 --- a/topsites.c +++ b/topsites.c @@ -275,7 +275,7 @@ void topsites(void) fputs("\"> ",fp_ou); } - output_html_link(fp_ou,url,100); + output_html_link(fp_ou,NULL,url,100); fputs("%s",fixnum(twork1,1)); diff --git a/util.c b/util.c index 72bb12f..7fa2a25 100644 --- a/util.c +++ b/util.c @@ -1724,16 +1724,18 @@ void output_html_url(FILE *fp_ou,const char *url) so the A tag is not written around the host name. \param fp_ou The handle of the HTML file. + \param scheme The scheme to print in the link (http:// if the pointer is null). \param url The host to display in the HTML file. \param maxlen The maximum number of characters to print into the host name. */ -void output_html_link(FILE *fp_ou,const char *url,int maxlen) +void output_html_link(FILE *fp_ou,const char *scheme,const char *url,int maxlen) { if (url[0]==ALIAS_PREFIX) { // this is an alias, no need for a A tag output_html_string(fp_ou,url+1,100); } else { - fputs("",fp_ou); output_html_string(fp_ou,url,100);