Added an HTML segment filter.
This commit is contained in:
parent
2b84feb29f
commit
143621e01b
2 changed files with 31 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ use WebGUI::Session;
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
use WebGUI::HTML;
|
use WebGUI::HTML;
|
||||||
|
$html = WebGUI::HTML::cleanSegment($html);
|
||||||
$html = WebGUI::HTML::filter($html);
|
$html = WebGUI::HTML::filter($html);
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
@ -38,6 +39,33 @@ use WebGUI::Session;
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 cleanSegment ( html )
|
||||||
|
|
||||||
|
Returns an HTML segment that has been stripped of the <BODY> tag
|
||||||
|
and anything before it, as well as the </BODY> tag and anything
|
||||||
|
after it.
|
||||||
|
|
||||||
|
NOTE: This filter does have one exception, it leaves anything before
|
||||||
|
the <BODY> tag that is enclosed in <STYLE></STYLE> tags.
|
||||||
|
|
||||||
|
=item html
|
||||||
|
|
||||||
|
The HTML segment you want cleaned.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub cleanSegment {
|
||||||
|
my ($style, $value);
|
||||||
|
$value = $_[0];
|
||||||
|
$value =~ m/(\<style.*?\/style\>)/ixsg;
|
||||||
|
$style = $1;
|
||||||
|
$value =~ s/\A.*?\<body.*?\>(.*?)/$style$1/ixsg;
|
||||||
|
$value =~ s/(.*?)\<\/body\>.*?\z/$1/ixsg;
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 filter ( html [, filter ] )
|
=head2 filter ( html [, filter ] )
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ use DBI;
|
||||||
use strict qw(subs vars);
|
use strict qw(subs vars);
|
||||||
use Tie::IxHash;
|
use Tie::IxHash;
|
||||||
use WebGUI::DateTime;
|
use WebGUI::DateTime;
|
||||||
|
use WebGUI::HTML;
|
||||||
|
use WebGUI::HTMLForm;
|
||||||
use WebGUI::Icon;
|
use WebGUI::Icon;
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::Macro;
|
use WebGUI::Macro;
|
||||||
|
|
@ -436,6 +438,7 @@ sub www_editSave {
|
||||||
$templatePosition = $session{form}{templatePosition} || 'A';
|
$templatePosition = $session{form}{templatePosition} || 'A';
|
||||||
$startDate = setToEpoch($session{form}{startDate}) || setToEpoch(time());
|
$startDate = setToEpoch($session{form}{startDate}) || setToEpoch(time());
|
||||||
$endDate = setToEpoch($session{form}{endDate}) || setToEpoch(time()+315360000);
|
$endDate = setToEpoch($session{form}{endDate}) || setToEpoch(time()+315360000);
|
||||||
|
$session{form}{description} = WebGUI::HTML::cleanSegment($session{form}{description});
|
||||||
$_[0]->set({
|
$_[0]->set({
|
||||||
title=>$title,
|
title=>$title,
|
||||||
displayTitle=>$session{form}{displayTitle},
|
displayTitle=>$session{form}{displayTitle},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue