Skip to content

Commit

Permalink
Item15154: keep images and links in rss feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jul 7, 2022
1 parent 7a11b1d commit 62c0368
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions core/lib/Foswiki/UI/View.pm
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,11 @@ sub view {
$end = '';
}

# If minimalist is set, images and anchors will be stripped from text
my $minimalist = 0;
if ($contentType) {
$minimalist = ( $session->getSkin() =~ m/\brss/ );
}
elsif ( $session->getSkin() =~ m/\brss/ ) {
if ( $session->getSkin() =~ m/\brss/ ) {
$contentType = 'text/xml';
$minimalist = 1;
}
elsif ( $session->getSkin() =~ m/\bxml/ ) {
$contentType = 'text/xml';
$minimalist = 1;
}
elsif ( $raw eq 'text' || $raw eq 'all' ) {
$contentType = 'text/plain';
Expand Down Expand Up @@ -435,10 +428,8 @@ sub view {
$page = $text;
}
else {
my @args = ( $topicObject, $minimalist );

$session->enterContext('header_text');
$page = _prepare( $start, @args );
$page = _prepare( $start, $topicObject );
$session->leaveContext('header_text');
Monitor::MARK('Rendered header');

Expand All @@ -458,13 +449,13 @@ sub view {
}
else {
$session->enterContext('body_text');
$page .= _prepare( $text, @args );
$page .= _prepare( $text, $topicObject );
$session->leaveContext('body_text');
}

Monitor::MARK('Rendered body');
$session->enterContext('footer_text');
$page .= _prepare( $end, @args );
$page .= _prepare( $end, $topicObject );
$session->leaveContext('footer_text');
Monitor::MARK('Rendered footer');
}
Expand All @@ -476,18 +467,12 @@ sub view {
}

sub _prepare {
my ( $text, $topicObject, $minimalist ) = @_;
my ( $text, $topicObject ) = @_;

$text = $topicObject->expandMacros($text);
$text = $topicObject->renderTML($text);
$text =~ s/( ?) *<\/?(nop|noautolink)\/?>\n?/$1/gis;

if ($minimalist) {
$text =~ s/<img [^>]*>//gi; # remove image tags
$text =~ s/<a [^>]*>//gi; # remove anchor tags
$text =~ s/<\/a>//gi; # remove anchor tags
}

return $text;
}

Expand Down Expand Up @@ -584,7 +569,7 @@ sub revisionsAround {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-2022 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down

0 comments on commit 62c0368

Please sign in to comment.