Changeset 990

Show
Ignore:
Timestamp:
03/24/07 23:24:17 (20 months ago)
Author:
kake
Message:

Strip leading/trailing whitespace from node_image fields before committing (ticket #197).

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides/Template.pm

    r937 r990  
    331331            my $value = $args{metadata} ? $metadata{$key}[0] 
    332332                                        : $q->param( $key ); 
     333            if ( $value ) { 
     334                $value =~ s/^\s+//g; 
     335                $value =~ s/\s+$//g; 
     336            } 
    333337            $vars{$key} = $value if $value; 
    334338        } 
  • trunk/t/44_node_image.t

    r956 r990  
    1616} 
    1717 
    18 plan tests => 28; 
     18plan tests => 30; 
    1919 
    2020my ( $config, $guide, $wiki ); 
     
    187187Test::HTML::Content::text_ok( $output, "http://eg.com/~kake/", 
    188188                              "...as does new node_image_url value" ); 
     189 
     190# Write node with node_image field consisting only of whitespace, make 
     191# sure it gets stripped. 
     192OpenGuides::Test->write_data( 
     193                              guide => $guide, 
     194                              node  => "Angel and Greyhound", 
     195                              node_image => " ", 
     196                            ); 
     197%node_data = $wiki->retrieve_node( "Angel and Greyhound" ); 
     198#use Data::Dumper; print Dumper \%node_data; 
     199ok( !$node_data{metadata}{node_image}, 
     200    "node_image of whitespace only isn't saved to database" ); 
     201 
     202$output = $guide->display_node( 
     203                                id            => "Angel and Greyhound", 
     204                                return_output => 1, 
     205                              ); 
     206$output =~ s/^Content-Type.*[\r\n]+//m; 
     207Test::HTML::Content::no_tag( $output, "img" => { id => "node_image" }, 
     208                             "...or displayed on page" );