Added an HTML segment filter.

This commit is contained in:
JT Smith 2002-05-23 05:37:28 +00:00
parent 2b84feb29f
commit 143621e01b
2 changed files with 31 additions and 0 deletions

View file

@ -25,6 +25,7 @@ use WebGUI::Session;
=head1 SYNOPSIS
use WebGUI::HTML;
$html = WebGUI::HTML::cleanSegment($html);
$html = WebGUI::HTML::filter($html);
=head1 DESCRIPTION
@ -38,6 +39,33 @@ use WebGUI::Session;
=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 ] )

View file

@ -19,6 +19,8 @@ use DBI;
use strict qw(subs vars);
use Tie::IxHash;
use WebGUI::DateTime;
use WebGUI::HTML;
use WebGUI::HTMLForm;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Macro;
@ -436,6 +438,7 @@ sub www_editSave {
$templatePosition = $session{form}{templatePosition} || 'A';
$startDate = setToEpoch($session{form}{startDate}) || setToEpoch(time());
$endDate = setToEpoch($session{form}{endDate}) || setToEpoch(time()+315360000);
$session{form}{description} = WebGUI::HTML::cleanSegment($session{form}{description});
$_[0]->set({
title=>$title,
displayTitle=>$session{form}{displayTitle},