Ignore:
Timestamp:
05/24/09 12:15:55 (3 years ago)
Author:
CrawfordCurrie
Message:

Item1603: use quotes to protect topic names with odd characters in them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm

    r3947 r3974  
    133133    }; 
    134134 
    135     my $ret = Foswiki::Contrib::MailerContrib::parsePageList( $subscribed, $who, 
    136         $topicList ); 
     135    my $ret = parsePageList( $subscribed, $who, $topicList ); 
    137136 
    138137    return ( !defined( $subscribed->{not_subscribed} ) 
     
    165164        push( @{ $subscribed->{not_subscribed} }, $stopic ); 
    166165    } 
    167     return ''; 
    168166} 
    169167 
    170168=pod 
     169 
    171170---+++ sub parsePageList ( $object, $who, $spec, $unsubscribe ) => unprocessable remainder of $spec line 
    172 calls the $topicSub (ref to sub) once per identified topic entry. 
    173    * $object (is a hashref) can be used to set status' and its definition is dependent on $topicSub 
    174    * $object->{topicSub} _must_ be a sub ref and _must_ return an empty string 
    175    * $unsubscribe can be set to '-' to force an unsubscription (used by SubscribePlugin) 
    176     
    177    $object is a functor. 
     171Calls the $object->{topicSub} once per identified topic entry. 
     172   * $object (a hashref) may be a hashref that has the field, =topicSub=, 
     173     which _may_ be a sub ref as follows: 
     174     =&topicSub($object, $who, $unsubscribe, $webTopic, $options, $childDepth)= 
     175   * =$unsubscribe= can be set to '-' to force an unsubscription 
     176     (used by SubscribePlugin) 
    178177 
    179178=cut 
     
    184183    #ASSERT(defined($object->{topicSub})); 
    185184 
    186     return $spec if ( !defined( $object->{topicSub} ) ); 
     185    return $spec if ( !$object || !defined( $object->{topicSub} ) ); 
    187186 
    188187    $spec =~ s/,/ /g; 
    189188 
    190     #TODO: refine the $2 regex to be proper web.topic/topic/* style.. 
     189    # $1: + or -, optional 
     190    # $2: the wildcarded topic specifier (may be quoted) 
     191    # TODO: refine the $2 regex to be proper web.topic/topic/* style.. 
     192    # $3: options 
     193    # $4: child depth 
    191194    while ( $spec =~ 
    192 s/^\s*([+-])?\s*([\w.\*]+)([!?]?)\s*(?:\((\d+)\))?/&{$object->{topicSub}}($object, $who, $unsubscribe||$1, $2, $3, $4)/e 
    193       ) 
    194     { 
    195  
     195              s/^\s*([+-])?\s*([*\w.]+|'.*?'|".*?")([!?]?)\s*(?:\((\d+)\))?//) { 
     196        my ( $us, $webTopic, $options, $childDepth ) = ( 
     197            $unsubscribe||$1||'+', $2, $3, $4||0 ); 
     198        $webTopic =~ s/^(['"])(.*)\1$/$2/; # remove quotes 
     199        &{$object->{topicSub}}( 
     200            $object, $who, $us, $webTopic, $options, $childDepth); 
    196201        #go 
    197202    } 
     
    205210    if ( !Foswiki::Func::webExists($web) ) { 
    206211 
    207         #        print STDERR "**** ERROR mailnotifier cannot find web $web\n"; 
     212        # print STDERR "**** ERROR mailnotifier cannot find web $web\n"; 
    208213        return ''; 
    209214    } 
Note: See TracChangeset for help on using the changeset viewer.