Loading...
 

Limited number of single nested plugins, which should not be limited

Status
Closed
Subject
Limited number of single nested plugins, which should not be limited
Version
8.x
17.x
Category
  • Consistency
  • Less than 30-minutes fix
Resolution status
Partially solved
Submitted by
edwinbennink
Volunteered to solve
Jonny Bradley
Lastmod by
drsassafras
Rating
(0)
Description

When you place more then 167 nested plugins of for example DIV (so not nested in nested in nested..., just plugins with only one nested plugin each). It will eventually not parse the plugin anymore.

Wikicode:

.
.
.
{DIV(id="test1")}test1{DIV(id="test2")}test2{DIV}{DIV}
{DIV(id="test1")}test1{DIV(id="test2")}test2{DIV}{DIV}
{DIV(id="test1")}test1{DIV(id="test2")}test2{DIV}{DIV}
.
.
.


The result will be:

test1
test2
.
.
.
test1
test2
test1{DIV(id="test2")}test2{DIV}
.
.
.
test1{DIV(id="test2")}test2{DIV}


This is due to a counter (passes) within the PluginMatcher.php which is limited to 500. But I'm guessing this counter is meant to avoid 500 nested in nested in nested in nested...etc (which indeed make sense to me), but not that this keeps counting when you start a new plugin.

I think there should be some attention to the levels. It seems that level zero is the whole text and that level one is simply the detection of the plugin, level two is the detection of a nested plugin, level 3 is the detection of a nested in nested plugin etc.

I haven't figured it out completely, but I have found a workaround to make the counter count as espected. But this is again a workaround and a real solution is needed.

Edit: More info...it "goes wrong" when the performReplace function is called, which itself calls the getSubMatcher function again, which increases the level (for which I believe should not happen the first time it is called). Whithin the findMatches (which also calls the getSubMatcher) there is a test whether the $this->level is empty and if so, the passes-counter is restored to zero. This test is missing within performReplace, but should maybe also be added? The problem is then that the passes-counter should be also known by the other functions. Shouldn't be difficult to do.

Solution

A preference was added to tiki in r62772 that allows one to increase the maximum number of passes, thus increasing the number of passes.

I've added the $this-level-is empty test within the performReplace function. To do this I globally defined the passes variable.

*** old//lib/core/WikiParser/PluginMatcher.php	Sat Oct  1 20:18:38 2011
--- new//lib/core/WikiParser/PluginMatcher.php	Wed May  9 10:41:13 2012
***************
*** 19,24 ****
--- 19,26 ----
  
  	private $leftOpen = 0;
  
+ 	private $passes = 0;
+ 
  	public static function match( $text )
  	{
  		$matcher = new self;
***************
*** 32,37 ****
--- 34,40 ----
  	{
  		$sub = new self;
  		$sub->level = $this->level + 1;
+ 		$sub->passes = $this->passes;
  		$sub->text = $this->text;
  		$sub->findMatches( $start, $end );
  
***************
*** 53,65 ****
  
  	function findMatches( $start, $end )
  	{
- 		static $passes;
- 
  		if ($this->level === 0) {
! 			$passes = 0;
  		}
  
! 		if (++$passes > 500) {
  			return;
  		}
  
--- 56,66 ----
  
  	function findMatches( $start, $end )
  	{
  		if ($this->level === 0) {
! 			$this->passes = 0;
  		}
  
! 		if (++$this->passes > 500) {
  			return;
  		}
  
***************
*** 115,121 ****
  						$pos = $match->getEnd();
  						--$this->leftOpen;
  						if (empty($this->level))
! 							$passes = 0;
  						break;
  					}
  
--- 116,122 ----
  						$pos = $match->getEnd();
  						--$this->leftOpen;
  						if (empty($this->level))
! 							$this->passes = 0;
  						break;
  					}
  
***************
*** 270,275 ****
--- 271,278 ----
  		$sub = $this->getSubMatcher( $start, $start + strlen( $string ) );
  		if ($sub->isComplete()) {
  			$this->appendSubMatcher($sub);
+ 			if (empty($this->level))
+ 				$this->passes = 0;
  		}
  
  		ksort( $this->ends );
Workaround

Because level one seem to be the detection of the plugin, the check when the counter (passes) should be restored to one, needs to be adjusted.

Change in line 58 in file <tikiroot>/lib/core/WikiParser/PluginMatcher.php:

if ($this->level === 0) {
        $passes = 0;
}


for:

if ($this->level <= 1) {
	$passes = 0;
}

Importance
5
Priority
25
Demonstrate Bug (Tiki 19+)
Please demonstrate your bug on show2.tikiwiki.org
 About show2.tikiwiki.org

To help developers solve the bug, we kindly request that you demonstrate your bug on a show2.tikiwiki.org instance. To start, simply select a version and click on "Create show2.tikiwiki.org instance". Once the instance is ready (in a minute or two), as indicated in the status window below, you can then access that instance, login (the initial admin username/password is "admin") and configure the Tiki to demonstrate your bug. Priority will be given to bugs that have been demonstrated on show2.tikiwiki.org.

Version: Create show2.tikiwiki.org instance
Ticket ID
4217
Created
Wednesday 09 May, 2012 08:04:11 GMT-0000
by edwinbennink
LastModif
Sunday 28 May, 2017 00:25:31 GMT-0000

Attachments

 filenamecreatedhitscommentversionfiletype 
No attachments for this item


Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.

Accessibility (WAI & 508)
Accounting
Administration
Ajax
Articles & Submissions
Backlinks
Banner
Batch
BigBlueButton audio/video/chat/screensharing
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution
Cookie
Copyright
Credits
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Diagram
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs
DogFood
Draw -superseded by Diagram
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Gantt
Group
Groupmail
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping
Mobile
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Packages
Payment
PDF
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Scheduler
Score
Search engine optimization (SEO)
Search
Security
Semantic links
Share
Shopping Cart
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags
Task
Tell a Friend
Terms and Conditions
Theme
TikiTests
Timesheet
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
Webmail and Groupmail
WebServices
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives
WYSIWTSN
WYSIWYCA
WYSIWYG
XMLRPC
XMPP




Useful Tools

Show PHP error messages