Changeset 4292


Ignore:
Timestamp:
06/24/09 19:37:44 (3 years ago)
Author:
MichaelTempest
Message:

Item1770: Protect the XML-like tags themselves, and not just the content within the tags
Call the callback function passed to adXMLTag
Add first unit tests for XML-like tag handling

Location:
trunk/WysiwygPlugin
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm

    r3992 r4292  
    600600    my ( $this, $text ) = @_; 
    601601 
     602    my $xmltags = $this->{opts}->{xmltag}; 
    602603    # Take out custom XML tags 
    603604    sub _takeOutCustomXmlProcess { 
    604605        my ( $this, $state, $scoop ) = @_; 
    605         return $this->_liftOut( $scoop, 'PROTECTED' ); 
    606     } 
    607     my $xmltags = $this->{opts}->{xmltag}; 
    608     for my $tag ( sort keys %$xmltags ) { 
     606        my $params = $state->{tagParams}; 
     607        my $tag = $state->{tag}; 
     608        my $markup = "<$tag$params>$scoop</$tag>"; 
     609        if ($this->{opts}->{xmltag}->{$tag}->($markup)) { 
     610            return $this->_liftOut( $markup, 'PROTECTED' ); 
     611        } 
     612        else { 
     613            return $this->_liftOut( "<$tag$params>", 'PROTECTED' ) . $scoop . $this->_liftOut( "</$tag>", 'PROTECTED' ); 
     614        } 
     615    } 
     616    for my $tag ( sort keys %{ $this->{opts}->{xmltag} } ) { 
    609617        $text = _takeOutXml( $this, $text, $tag, \&_takeOutCustomXmlProcess ); 
    610618    } 
     
    646654 
    647655    # &$fn may rely on the existence of these fields,  
    648         # and may add more fields, if needed 
     656    # and may add more fields, if needed 
    649657    my %state = ( tag => $tag, n => 0, tagParams => undef ); 
    650658 
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/WysiwygPluginSuite.pm

    r3944 r4292  
    2626 
    2727sub include_tests { 
    28     return qw(TranslatorTests WysiwygPluginTests); 
     28    return qw(TranslatorTests ExtendedTranslatorTests WysiwygPluginTests); 
    2929} 
    3030 
Note: See TracChangeset for help on using the changeset viewer.