|
From: David H. <dav...@st...> - 2008-01-31 19:09:31
|
Hi, I am trying to improve the presentation of Sarg reports within Webmin but there is a regular expression bug in the Sarg module's view.cgi module that is causing me grief. The Sarg module's view.cgi file reads an html Sarg report and strips out the content up to the end of the <body> tag. The problem is it seems like the regular expression has been written with the expectation the the <body> tag of a Sarg report will be on a unique line to the rest of the report. Consequently a Sarg report like the following displays great within Webmin: <body class="body"> <center><table cellpadding=0 cellspacing=0> <tr> Whilst a report that doesn't have <body> on a distinct line will not: <body class="body"><center><table cellpadding=0 cellspacing=0> <tr> This is because rather than removing everything up to the end of the body tag the regular expression is dropping the entire line :-( This results in unpaired html tags and varying levels of screen chaos depending on the Webmin theme applied. Lines 27 & 28 of sarg/view.cgi do the dirty work and they are as follows: $data =~ s/^[\000-\377]*<BODY.*>//i; $data =~ s/<\/BODY>[\000-\377]*$//i; I've tried on numerous times to understand regular expressions to no avail. Can someone out there suggest a way of tweaking line 27 of view.cgi so that it does not remove any report content that proceeds the <body> tag if it is on the same line? Regards, David Harrison |
|
From: Colm D. <col...@gm...> - 2008-01-31 19:18:09
|
On Jan 31, 2008 7:09 PM, David Harrison <dav...@st...> wrote: > > Lines 27 & 28 of sarg/view.cgi do the dirty work and they are as > follows: > $data =~ s/^[\000-\377]*<BODY.*>//i; > $data =~ s/<\/BODY>[\000-\377]*$//i; If i understand the problem correctly, I think making the .* after the BODY non-greedy, by adding a question mark, will solve it, i.e. : $data =~ s/^[\000-\377]*<BODY.*?>//i; Colm |
|
From: David H. <dav...@st...> - 2008-01-31 20:17:53
|
Hi,
This is a tiny patch that takes on board Colm's correct advice about
the regular expression and adds an encapsulating div block around the
Sarg report data.
I've never submitted a patch before so this maybe the completely wrong
way of going about doing it :-)
It changes no functionality but makes the job of theming Sarg reports
within Webmin a whole lot easier.
David
--- sarg/view.cgi 2008-02-01 08:46:40.000000000 +1300
+++ sarg/view.cgi 2008-02-01 08:46:29.000000000 +1300
@@ -24,11 +24,13 @@ if ($full =~ /\.(html|htm)$/i && !$confi
if ($data =~ /<TITLE>(.*)<\/TITLE>/i) {
$title = $1;
}
- $data =~ s/^[\000-\377]*<BODY.*>//i;
+ $data =~ s/^[\000-\377]*<BODY.*?>//i;
$data =~ s/<\/BODY>[\000-\377]*$//i;
&header($title || $text{'view_title'}, "");
+ print "<div id=\"sarg-report\">\n";
print $data;
+ print "</div>\n";
&footer("", $text{'index_return'});
}
else {
On 1/02/2008, at 8:17 AM, Colm Dougan wrote:
> On Jan 31, 2008 7:09 PM, David Harrison
> <dav...@st...> wrote:
>>
>> Lines 27 & 28 of sarg/view.cgi do the dirty work and they are as
>> follows:
>> $data =~ s/^[\000-\377]*<BODY.*>//i;
>> $data =~ s/<\/BODY>[\000-\377]*$//i;
>
> If i understand the problem correctly, I think making the .* after the
> BODY non-greedy, by adding a question mark, will solve it, i.e. :
>
> $data =~ s/^[\000-\377]*<BODY.*?>//i;
>
> Colm
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> -
> Forwarded by the Webmin development list at web...@we...
> To remove yourself from this list, go to
> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
|
|
From: Jamie C. <jca...@we...> - 2008-01-31 20:25:50
|
Hi David,
Thanks for the patch - I will include this in the next Webmin release.
- Jamie
On 31/Jan/2008 12:17 David Harrison wrote ..
> Hi,
> This is a tiny patch that takes on board Colm's correct advice about
> the regular expression and adds an encapsulating div block around the
> Sarg report data.
> I've never submitted a patch before so this maybe the completely wrong
> way of going about doing it :-)
>
> It changes no functionality but makes the job of theming Sarg reports
> within Webmin a whole lot easier.
>
>
> David
>
>
>
>
> --- sarg/view.cgi 2008-02-01 08:46:40.000000000 +1300
> +++ sarg/view.cgi 2008-02-01 08:46:29.000000000 +1300
> @@ -24,11 +24,13 @@ if ($full =~ /\.(html|htm)$/i && !$confi
> if ($data =~ /<TITLE>(.*)<\/TITLE>/i) {
> $title = $1;
> }
> - $data =~ s/^[\000-\377]*<BODY.*>//i;
> + $data =~ s/^[\000-\377]*<BODY.*?>//i;
> $data =~ s/<\/BODY>[\000-\377]*$//i;
>
> &header($title || $text{'view_title'}, "");
> + print "<div id=\"sarg-report\">\n";
> print $data;
> + print "</div>\n";
> &footer("", $text{'index_return'});
> }
> else {
>
>
>
>
>
> On 1/02/2008, at 8:17 AM, Colm Dougan wrote:
>
> > On Jan 31, 2008 7:09 PM, David Harrison
> > <dav...@st...> wrote:
> >>
> >> Lines 27 & 28 of sarg/view.cgi do the dirty work and they are as
> >> follows:
> >> $data =~ s/^[\000-\377]*<BODY.*>//i;
> >> $data =~ s/<\/BODY>[\000-\377]*$//i;
> >
> > If i understand the problem correctly, I think making the .* after the
> > BODY non-greedy, by adding a question mark, will solve it, i.e. :
> >
> > $data =~ s/^[\000-\377]*<BODY.*?>//i;
> >
> > Colm
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > -
> > Forwarded by the Webmin development list at web...@we...
> > To remove yourself from this list, go to
> > http://lists.sourceforge.net/lists/listinfo/webadmin-devel
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> -
> Forwarded by the Webmin development list at web...@we...
> To remove yourself from this list, go to
> http://lists.sourceforge.net/lists/listinfo/webadmin-devel
|