Weird TPL error

Hello Expert,

My TS version 16.6.1.1 installed o RHEL 7.7.

We recently migrated from TS 7.5 to TS 16.6.1.1. We still using TPL file to generate html files. After the upgrade we were facing this very weird issue where extra content can be seen on generated HTML pages after removing some content from DCR. There were few old PERL module issue I fixed but I am not able to debug this issue. Below is code which we are using to generate HTML files:

<iw_comment>Free-form text content</iw_comment>
<iw_case type='text'>
<iw_perl><![CDATA[
my $textContent = iwpt_dcr_value('contentElement');
if ((defined $textContent) && ($textContent !~ /^\s*$/)) {
my $myCopy = $textContent;
$textContent = $ptHandler->cleanseText($pageName, $textContent);
if (! defined $textContent) {
$textContent = $myCopy;
}
}
]]></iw_perl>
<iw_value name='$textContent'/>
</iw_case>
cleanseText function from PTHandler.pm

sub cleanseText {
# Get parameters
my $this = shift;
my $pagePath = shift;
my $textContent = shift;
my $cleansedText = '';
my $tree;
$tree = HTML::TreeBuilder->new;
$tree->parse($textContent);
my @allLinkTags = $tree->find_by_tag_name('a','map');
foreach my $tag (@allLinkTags) {
    my $href = $tag->attr('href');
# If href attribute exist and pagePath been passed
    if ( (defined $href ) && (defined $pagePath) ) {
# Fix the link
my $link = &fixLink($this, $href, $pagePath);
# If able to fix the link
if (defined $link) {
# Replace the href attribute with the fixed link
$tag->attr('href', $link);
}
    }
}
$cleansedText = &trimHtml($tree->as_HTML(undef, ' ', {} ));
$cleansedText =~ s/<br>/<br\/>/sg if ($cleansedText =~ /<br>/);
#print STDERR "cleanseText OUPUT: " . $cleansedText . "\n";
return $cleansedText;
}
Please help me to debug this issue because I have tried all my perl and tpl knowledge but could not find the root cause itself.

Thanks in Advance,
Niraj

Comments

Sign In or Register to comment.