SID-00025: CommentPlugin loses data
| Status: |
Answered |
TWiki version: |
4.2.3 |
Perl version: |
5.8.8 |
| Category: |
CategoryPlugins |
Server OS: |
Fedora core 6 |
Last update: |
17 years ago |
The
CommentPlugin loses data if it's targeted before/after a missing anchor.
Consider this case:
%COMMENT{type="above" cols="100" target="%INCLUDINGTOPIC%#LatestComment"}%
Try adding a comment here:
The specified anchor does not exist - in this case, it was corrupted by the WYSIWYG plugin. Comment.pm tries a s//, but doesn't notice that it fails.
In any case, an error setting up the page should not cause user data to be lost. I marked this report Urgent because it results in user data loss.
Here's a (somewhat ugly) patch:
--- lib/TWiki/Plugins/CommentPlugin/Comment.pm~ 2008-09-11 23:41:58.000000000 -0400
+++ lib/TWiki/Plugins/CommentPlugin/Comment.pm 2009-01-10 13:45:46.000000000 -0500
@@ -309,32 +309,35 @@
$text .= "\n" unless $output =~ m/^\n/s;
$text .= $output;
$text .= "\n" unless $text =~ m/\n$/s;
} else {
if ( $location ) {
if ( $position eq 'BEFORE' ) {
- $text =~ s/(?<!location\=\")($location)/$output$1/m;
+ $text .= $output unless( $text =~ s/(?<!location\=\")($location)/$output$1/m );
} else { # AFTER
- $text =~ s/(?<!location\=\")($location)/$1$output/m;
+ $text .= $output unless( $text =~ s/(?<!location\=\")($location)/$1$output/m );
}
+ $text .= "\n" unless $text =~ m/\n$/s;
} elsif ( $anchor ) {
# position relative to anchor
if ( $position eq 'BEFORE' ) {
- $text =~ s/^($anchor\s)/$output$1/m;
+ $text .= $output unless( $text =~ s/^($anchor\s)/$output$1/m );
} else { # AFTER
- $text =~ s/^($anchor\s)/$1$output/m;
+ $text .= $output unless( $text =~ s/^($anchor\s)/$1$output/m );
}
+ $text .= "\n" unless $text =~ m/\n$/s;
} else {
# Position relative to index'th comment
my $idx = 0;
unless( $text =~ s((%COMMENT({.*?})?%.*\n))
(&_nth($1,\$idx,$position,$index,$output))eg ) {
# If there was a problem adding relative to the comment,
# add to the end of the topic
$text .= $output;
};
+ $text .= "\n" unless $text =~ m/\n$/s;
}
}
}
if (defined $remove) {
# remove the index'th comment box
--
TimotheLitt - 10 Jan 2009
Discussion and Answer
Thanks Timothe. Please file a bug report at
TWikibug:CommentPlugin
to track this.
--
PeterThoeny - 10 Jan 2009
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.