--- TagMePlugin.pm.orig 2008-01-08 13:44:20.000000000 -0200 +++ TagMePlugin.pm 2008-01-09 14:21:11.000000000 -0200 @@ -125,6 +125,32 @@ } # ========================= +sub afterRenameHandler { + my ( $oldWeb, $oldTopic, $oldAttachment, $newWeb, $newTopic, $newAttachment ) = @_; + + _writeDebug("afterRenameHandler( $oldWeb.$oldTopic -> $newWeb.$newTopic)"); + + # Checks if topic name is empty and web name changed, to catch only web rename/move (topic rename/move is threated by afterSaveHandle) + if ( $newTopic eq '' && $oldTopic eq '' && $newWeb ne $oldWeb ) + { + _writeDebug(" - web renamed from $oldWeb.$oldTopic to $newWeb.$newTopic"); + _initialize(); + + $oldWeb =~ s/\./\//g; + foreach my $webTopic ( _getTagInfoList() ) { + $webTopic =~ s/\./\//g; + my $tagWeb = $webTopic; + $tagWeb =~ s/^(.*)\/(.*?)$/$1/; + my $tagTopic = $2; + if ($tagWeb eq $oldWeb) { + _writeDebug(" - topic renamed from $webTopic to $newWeb/$tagTopic"); + renameTagInfo( $webTopic, "$newWeb.$tagTopic" ); + } + } + } +} + +# ========================= sub commonTagsHandler { ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead @@ -1054,6 +1080,11 @@ $oldWebTopic =~ s/[\/\\]/\./g; $newWebTopic =~ s/[\/\\]/\./g; + + # Untaint $oldWebTopic + if ($oldWebTopic =~ /^([-\@\w.]+)$/) { + $oldWebTopic = $1; + } my $oldFile = "$workAreaDir/_tags_$oldWebTopic.txt"; my $newFile = "$workAreaDir/_tags_$newWebTopic.txt"; if ( -e $oldFile ) {