]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fix the link to the URL in some reports
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 6 Jan 2012 13:08:58 +0000 (13:08 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 6 Jan 2012 13:08:58 +0000 (13:08 +0000)
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.

authfail.c
dansguardian_report.c
denied.c
download.c
html.c
include/defs.h
redirector.c
siteuser.c
topsites.c
util.c

index 8e74f78487f339c16765e08a38f1662c724cc48e..fd3d99d9ecd873538d1dec64c95f1422b79372e2 100644 (file)
@@ -189,7 +189,7 @@ void authfail_report(void)
                        output_html_url(fp_ou,url);
                        fputs("\"><img src=\"../images/sarg-squidguard-block.png\"></a>&nbsp;",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("</td></th>\n",fp_ou);
        }
        fclose(fp_in);
index 0bf7b48f374a5ff021fb237c0298caf81b0d05fa..93b80d76c73ab060d8afb7abd98b3e58cc356505 100644 (file)
@@ -155,7 +155,7 @@ void dansguardian_report(void)
                }
 
                fprintf(fp_ou,"<tr><td class=\"data2\">%s</td><td class=\"data2\">%s</td><td class=\"data2\">%s-%s</td><td class=\"data2\">",name,ip,date,hour);
-               output_html_link(fp_ou,url,100);
+               output_html_link(fp_ou,NULL,url,100);
                fprintf(fp_ou,"</td><td class=\"data2\">%s</td></tr>\n",rule);
        }
        fclose(fp_in);
index ec8505cc294b59dd25710920875730979e3fd2aa..db49aa78d94f6001f35e9fbd68e42303cd586dc4 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -158,7 +158,7 @@ void gen_denied_report(void)
                        output_html_url(fp_ou,url);
                        fprintf(fp_ou,"\"><img src=\"%s/sarg-squidguard-block.png\"></a>&nbsp;",ImageFile);
                }
-               output_html_link(fp_ou,url,100);
+               output_html_link(fp_ou,"",url,100); //the URL contains the scheme
                fputs("</td></tr>\n",fp_ou);
        }
        fclose(fp_in);
index 75421a6d20529278bef6df5564b5eac77b88a576..51cb098c32840d22ee13c3cfe2428acc43f9d9b7 100644 (file)
@@ -156,7 +156,7 @@ void download_report(void)
                        output_html_url(fp_ou,url);
                        fprintf(fp_ou,"\"><img src=\"%s/sarg-squidguard-block.png\"></a>&nbsp;",ImageFile);
                }
-               output_html_link(fp_ou,url,100);
+               output_html_link(fp_ou,"",url,100);//scheme is kept from the log file
                fputs("</td></tr>\n",fp_ou);
        }
        fclose(fp_in);
diff --git a/html.c b/html.c
index 84db764f4caa1d5bf654533009f0397e32671cd3..b38d81e19a4329cb8e7f196c122059eb4e0225a3 100644 (file)
--- a/html.c
+++ b/html.c
@@ -285,7 +285,7 @@ void htmlrel(void)
                                                output_html_url(fp_ou,url);
                                                fprintf(fp_ou,"\"><img src=\"%s/sarg-squidguard-block.png\"></a>&nbsp;",tmp6);
                                        }
-                                       output_html_link(fp_ou,url,100);
+                                       output_html_link(fp_ou,NULL,url,100);
                                        fputs("</td>",fp_ou);
                                }
 
index d24238de00e626de3d00cdd8fbade2d48b5d2cd8..403b335a4f6d4f973e829c6985283de9ee562810 100755 (executable)
@@ -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);
index b8ab00de98fbd0987dec757b6559ebbe614abf1d..9e1ca674fb49011822864ec37012f2346a107fb7 100644 (file)
@@ -552,7 +552,7 @@ void redirector_report(void)
                else
                        fputs("<tr><td class=\"data2\"></td><td class=\"data2\"></td>",fp_ou);
                fprintf(fp_ou,"<td class=\"data2\">%s-%s</td><td class=\"data2\">",data,hora);
-               output_html_link(fp_ou,url,100);
+               output_html_link(fp_ou,NULL,url,100);
                fprintf(fp_ou,"</td><td class=\"data2\">%s</td></tr>\n",rule);
        }
        fclose(fp_in);
index 997b27193567efcb6c3dd3fa32c73c79c6ec5769..a1c874373f47cf8a9356d3d9128fb75e2c2bb75b 100644 (file)
@@ -146,7 +146,7 @@ void siteuser(void)
                                output_html_url(fp_ou,ourl);
                                fputs("\"><img src=\"../images/sarg-squidguard-block.png\"></a>&nbsp;",fp_ou);
                        }
-                       output_html_link(fp_ou,ourl,100);
+                       output_html_link(fp_ou,NULL,ourl,100);
                        fputs("</td>",fp_ou);
 
                        if (BytesInSitesUsersReport) {
index e361331676fd8587fd159d620ffbd5773eb67b26..9c05b211791c7b024f385726f481e5bc323dd981 100644 (file)
@@ -275,7 +275,7 @@ void topsites(void)
                        fputs("\"><img src=\"../images/sarg-squidguard-block.png\"></a>&nbsp;",fp_ou);
                }
 
-               output_html_link(fp_ou,url,100);
+               output_html_link(fp_ou,NULL,url,100);
                fputs("</td><td class=\"data\"",fp_ou);
                if (SortTableJs[0]) fprintf(fp_ou," sorttable_customkey=\"%"PRId64"\"",(uint64_t)twork1);
                fprintf(fp_ou,">%s</td>",fixnum(twork1,1));
diff --git a/util.c b/util.c
index 72bb12fcff02cb73ac49683dd043fca37eb7acee..7fa2a256eae519f0ac41df6b8c7387ecccc99928 100644 (file)
--- 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("<a href=\"http://",fp_ou);
+               if (scheme==NULL) scheme="http://";
+               fprintf(fp_ou,"<a href=\"%s",scheme);
                output_html_url(fp_ou,url);
                fputs("\">",fp_ou);
                output_html_string(fp_ou,url,100);