Changeset 3974
- Timestamp:
- 05/24/09 12:15:55 (3 years ago)
- Location:
- trunk/MailerContrib
- Files:
-
- 5 edited
-
data/System/MailerContrib.txt (modified) (1 diff)
-
lib/Foswiki/Contrib/MailerContrib.pm (modified) (4 diffs)
-
lib/Foswiki/Contrib/MailerContrib/Subscription.pm (modified) (1 diff)
-
lib/Foswiki/Contrib/MailerContrib/WebNotify.pm (modified) (1 diff)
-
test/unit/MailerContrib/MailerContribSuite.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/MailerContrib/data/System/MailerContrib.txt
r3639 r3974 163 163 | Version: | %$VERSION% | 164 164 | Change History: | | 165 | 24 May 2009 | Foswikitask:Item1603: use quotes to protect topic names with odd characters in them | 165 166 | 23 Apr 2009 | Foswikitask:Item1501: Minor bug in logfile output fixed | 166 167 | 03 Dec 2008 | Re-released for the Foswiki project | -
trunk/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm
r3947 r3974 133 133 }; 134 134 135 my $ret = Foswiki::Contrib::MailerContrib::parsePageList( $subscribed, $who, 136 $topicList ); 135 my $ret = parsePageList( $subscribed, $who, $topicList ); 137 136 138 137 return ( !defined( $subscribed->{not_subscribed} ) … … 165 164 push( @{ $subscribed->{not_subscribed} }, $stopic ); 166 165 } 167 return '';168 166 } 169 167 170 168 =pod 169 171 170 ---+++ 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 $topicSub174 * $object->{topicSub} _must_ be a sub ref and _must_ return an empty string175 * $unsubscribe can be set to '-' to force an unsubscription (used by SubscribePlugin)176 177 $object is a functor.171 Calls 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) 178 177 179 178 =cut … … 184 183 #ASSERT(defined($object->{topicSub})); 185 184 186 return $spec if ( ! defined( $object->{topicSub} ) );185 return $spec if ( !$object || !defined( $object->{topicSub} ) ); 187 186 188 187 $spec =~ s/,/ /g; 189 188 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 191 194 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); 196 201 #go 197 202 } … … 205 210 if ( !Foswiki::Func::webExists($web) ) { 206 211 207 # print STDERR "**** ERROR mailnotifier cannot find web $web\n";212 # print STDERR "**** ERROR mailnotifier cannot find web $web\n"; 208 213 return ''; 209 214 } -
trunk/MailerContrib/lib/Foswiki/Contrib/MailerContrib/Subscription.pm
r2957 r3974 68 68 my $record = $this->{topics}; 69 69 70 # convert RE back to wildcard 71 $record =~ s/\.\*\?/\*/; 70 # Protect non-alphanumerics in topic name 71 if ($record =~ /[^*\w.]/) { 72 if ($record =~ /'/) { 73 $record = "\"$record\""; 74 } else { 75 $record = "'$record'"; 76 } 77 } 72 78 $record .= $this->getMode(); 73 79 $record .= " ($this->{depth})" if ( $this->{depth} ); -
trunk/MailerContrib/lib/Foswiki/Contrib/MailerContrib/WebNotify.pm
r3639 r3974 417 417 $this->{topicSub} = \&_subscribeTopic; 418 418 419 my $ret = 420 Foswiki::Contrib::MailerContrib::parsePageList( $this, $who, $spec, 421 $unsubscribe ); 419 my $ret = Foswiki::Contrib::MailerContrib::parsePageList( 420 $this, $who, $spec, $unsubscribe ); 422 421 if ( $ret =~ m/\S/ ) { 423 Foswiki::Func::writeWarning("Badly formatted page list at $who: $spec"); 422 Foswiki::Func::writeWarning( 423 "Badly formatted page list at $who: $spec"); 424 424 return -1; 425 425 } -
trunk/MailerContrib/test/unit/MailerContrib/MailerContribSuite.pm
r3944 r3974 20 20 TestTopic122 => "r1->r2", 21 21 TestTopic1221 => "r1->r2", 22 TestTopic2=> "r2->r3",23 TestTopic21=> "r1->r2",22 'TestTopic2' => "r2->r3", 23 'TestTopic21' => "r1->r2", 24 24 ); 25 25 … … 34 34 TestTopic122 => "That danged robot", 35 35 TestTopic1221 => "What's up, Buck?", 36 TestTopic2=> "roast my nipple-nuts",37 TestTopic21=> "smoke me a kipper, I'll be back for breakfast",36 'TestTopic2' => "roast my nipple-nuts", 37 'TestTopic21' => "smoke me a kipper, I'll be back for breakfast", 38 38 39 39 # High-bit chars - assumes {Site}{CharSet} is set for a high-bit … … 145 145 { 146 146 email => "email4\@example.com", 147 entry => "email4\@example.com: TestTopic1 (0), TestTopic2(3)",147 entry => "email4\@example.com: TestTopic1 (0), 'TestTopic2' (3)", 148 148 topicsout => "TestTopic1 TestTopic2 TestTopic21" 149 149 }, … … 153 153 email => "email5\@example.com", 154 154 entry => 155 "email5\@example.com: TestTopic1 + TestTopic2(3), -TestTopic21",155 "email5\@example.com: TestTopic1 + 'TestTopic2'(3), -'TestTopic21'", 156 156 topicsout => "TestTopic1 TestTopic2" 157 157 }, … … 167 167 { 168 168 email => "email7\@example.com", 169 entry => "email7\@example.com: TestTopic*1 - \\\n TestTopic2*",169 entry => "email7\@example.com: TestTopic*1 - \\\n 'TestTopic2*'", 170 170 topicsout => "TestTopic1 TestTopic11 TestTopic121", 171 171 }, … … 338 338 ( $meta, $text ) = Foswiki::Func::readTopic( $web, "TestTopic2" ); 339 339 Foswiki::Func::saveTopic( $web, "TestTopic2", $meta, 340 $finalText{ TestTopic2}, { forcenewrevision => 1 } );340 $finalText{'TestTopic2'}, { forcenewrevision => 1 } ); 341 341 342 342 ( $meta, $text ) = Foswiki::Func::readTopic( $web, "TestTopic21" ); 343 343 Foswiki::Func::saveTopic( $web, "TestTopic21", $meta, 344 $finalText{ TestTopic21}, { forcenewrevision => 1 } );344 $finalText{'TestTopic21'}, { forcenewrevision => 1 } ); 345 345 346 346 # wait a wee bit more for the clock to tick over again
Note: See TracChangeset
for help on using the changeset viewer.
