Changeset 508


Ignore:
Timestamp:
11/10/08 04:10:56 (3 years ago)
Author:
SvenDowideit
Message:

Item124: undefined ICONTOPIC causes crash

Location:
trunk/core/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/lib/TWiki.pm

    r504 r508  
    12601260 
    12611261    my $iconTopic = $this->{prefs}->getPreferencesValue('ICONTOPIC'); 
    1262     my ( $web, $topic ) = 
    1263       $this->normalizeWebTopicName( $this->{webName}, $iconTopic ); 
    1264     $iconName =~ s/^.*\.(.*?)$/$1/; 
    1265     return $this->getPubUrl( $absolute, $web, $topic, $iconName . '.gif' ); 
     1262    if (defined($iconTopic)) { 
     1263        my ( $web, $topic ) = 
     1264            $this->normalizeWebTopicName( $this->{webName}, $iconTopic ); 
     1265        $iconName =~ s/^.*\.(.*?)$/$1/; 
     1266        return $this->getPubUrl( $absolute, $web, $topic, $iconName . '.gif' ); 
     1267    } ele { 
     1268        return ''; 
     1269    } 
    12661270} 
    12671271 
     
    12831287    unless ( $this->{_ICONMAP} ) { 
    12841288        my $iconTopic = $this->{prefs}->getPreferencesValue('ICONTOPIC'); 
    1285         my ( $web, $topic ) = 
    1286           $this->normalizeWebTopicName( $this->{webName}, $iconTopic ); 
    1287         local $/ = undef; 
    1288         try { 
    1289             my $icons = 
    1290               $this->{store} 
    1291               ->getAttachmentStream( undef, $web, $topic, '_filetypes.txt' ); 
    1292             %{ $this->{_ICONMAP} } = split( /\s+/, <$icons> ); 
    1293             close($icons); 
    1294         } 
    1295         catch Error::Simple with { 
    1296             %{ $this->{_ICONMAP} } = (); 
    1297         }; 
     1289        if (defined($iconTopic)) { 
     1290            my ( $web, $topic ) = 
     1291              $this->normalizeWebTopicName( $this->{webName}, $iconTopic ); 
     1292            local $/ = undef; 
     1293            try { 
     1294                my $icons = 
     1295                  $this->{store} 
     1296                  ->getAttachmentStream( undef, $web, $topic, '_filetypes.txt' ); 
     1297                %{ $this->{_ICONMAP} } = split( /\s+/, <$icons> ); 
     1298                close($icons); 
     1299            } 
     1300            catch Error::Simple with { 
     1301                %{ $this->{_ICONMAP} } = (); 
     1302            }; 
     1303        } else { 
     1304            return $default || $fileName; 
     1305        } 
    12981306    } 
    12991307 
  • trunk/core/lib/TWiki/Attach.pm

    r411 r508  
    195195    elsif ( $attr eq 'ICON' ) { 
    196196        my $picked = $this->{session}->mapToIconFileName($file); 
     197        if (!defined($picked) || ($picked eq '')) { 
     198            return ''; 
     199        } 
    197200        my $url = $this->{session}->getIconUrl( 0, $picked ); 
    198201        return CGI::img( 
Note: See TracChangeset for help on using the changeset viewer.