You are here: Foswiki>Tasks Web>Item11100 (30 Sep 2011, MichaelDaum)Edit Attach

Item11100: MediaWikiTablePlugin parses verbatim area

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: MediaWikiTablePlugin
Branches:
Reported By: AndreLichtsteiner
Waiting For:
Last Change By: MichaelDaum
In the attempt to put together some sample pages with documentation we observed the following faulty behaviour:

A table in mediawiki syntax, wrapped in a verbatim block, gets expanded in a included topic.

Details
  • TopicA contains a mediawiki table sample:
    <verbatim>
     {|
       table code goes here
     |}
     </verbatim>
     
  • This looks fine in TopicA
     {|
       table code goes here
     |}
  • TopicB includes TopicA
     %INCLUDE{"TopicA"}
     
  • Now, the block locks as following:
     <table class='wikitable' >
       table code goes here
     </td></tr>
     </table>
     

-- AndreLichtsteiner - 01 Sep 2011

I can confirm the problem.

Some analysis: MediaWikiTablePlugin processes the topic text using the commonTagsHandler() callback. The core however does take out all verbatim areas right before dispatching this handler (see Foswiki.pm). The only way for a commonTagsHandler to still see the internals of a verbatim area is that it did become a normal pre area already ... which is of course not taken out before calling the commonTagsHandler and that's why MediaWikiTablePlugin happily converts the markup. verbatim=s are converted to =pre=s as part of the renderer, not the macro parser. So part of the =%INCLUDE must have been some call to getRenderedVersion() ... too early for the verbatim to protect further processing.

Basically, implementing table rendering is wrong to be implemented using a macro handler. It should probably be one of the render handlers. Not yet sure which one.

Try this patch:

--- lib/Foswiki/Plugins/MediaWikiTablePlugin.pm (revision 12394)
+++ lib/Foswiki/Plugins/MediaWikiTablePlugin.pm (working copy)
@@ -16,6 +16,7 @@
 
 use strict;
 use Foswiki::Func ();
+use Foswiki::Plugins ();
 our $VERSION = '$Rev$';
 our $RELEASE = 'v1.30';
 our $NO_PREFS_IN_TOPIC = 1;
@@ -29,9 +30,12 @@
 }
 
 ###############################################################################
-sub commonTagsHandler {
-  # text, topic, web
-  handleMWTable($_[2], $_[1], $_[0]) if $_[0] =~ /(^|[\n\r])\s*{\|/;
+sub preRenderingHandler {
+  # text, \%map
+  my $session = $Foswiki::Plugins::SESSION;
+  my $web = $session->{webName};
+  my $topic = $session->{topicName};
+  handleMWTable($web, $topic, $_[0]) if $_[0] =~ /(^|[\n\r])\s*{\|/;
 }

-- MichaelDaum - 02 Sep 2011

Works fine, thanks.

Can I expect an updated Plugin soon or shall I deploy the patch?

-- AndreLichtsteiner - 06 Sep 2011

released as 1.31

-- MichaelDaum - 30 Sep 2011

ItemTemplate edit

Summary MediaWikiTablePlugin parses verbatim area
ReportedBy AndreLichtsteiner
Codebase
SVN Range
AppliesTo Extension
Component MediaWikiTablePlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins MediaWikiTablePlugin:d6bcf9fe2f7c
TargetRelease n/a
ReleasedIn n/a
Topic revision: r5 - 30 Sep 2011, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy