Forum OpenACS Development: Problem with includelet in xowiki

Collapse
Posted by Derick Leony on
I was having an issue with xowiki 0.63.3 (branch 5-3); the use of an includelet was generating this error message:

Error in includelet '{{adp portlets/public-blog {package_id 2370 }}' of page en:main_page:
Syntax: adp <name of adp-file> {<argument list>}
Invalid argument list: 'portlets/public-blog {package_id 2370 '; must be of form: attribute value pairs (even number of elements)
}

The last "}" is there on purpose.

The includelet is: {{adp portlets/public-blog {package_id 2370 }}}
The weird thing is that this was working on a previous version of xowiki.

I changed the include regular expresion from:
include {([^\\]){{([^<]+?)}}(\s|<|$)?}
to
include {([^\\]){{([^<]+)}}(\s|<|$)?}

since I believe in this case you do want a greedy RE.

This fixed this particular issue and I can't think of any other situation where it wouldn't work, but I'd like to know if this is actually correct before using it in a production environment.

Thanks.

Collapse
Posted by Byron Linares on
The problem is a easy fix you should change
{{adp portlets/public-blog {package_id 2370 }}}
For
{{adp portlets/public-blog {package_id 2370 } }}
And that it.
Collapse
Posted by Derick Leony on
Well, that's easier and more safe, I guess. Thanks!
Collapse
Posted by Dave Bauer on
Personally I find signifigant whitespace between the braces very annoying!

Tcl doesn't seem to require adding spaces between braces so it should be possible to parse them without requiring it.

Collapse
Posted by Gustaf Neumann on
The regular expressions are used for extracting included content from html pages. If the RE is made greedy, it might pick up the closing braces from a possibly following includelet definition - not desired either.

While it is certainly true that Tcl does not require whitespace to determine the correct closing braces, one should remember, that Tcl does not use regular expression to parse its syntax. Parsing of balanced braces in the general case is a well-known limitation of regular grammars. One needs at least context free grammars for this task. From the parsing point of view, it would be better to encode e.g. the wiki-markup in HTML (DIVS, SPANS), or to use a different parser (e.g. write a small parse in C), or to use one of the many wiki-style parsers around. All these approaches have some properties not desired either.

For now, i have improved the RE slightly to handle the mentioned cases correctly (in the 5-3 branch and on cvs head). This is no general solution, but pushes the boundary a little further. One should not use two closing curly braces next to each other within an includelet definition.

Note that the problem is as well a bigger problem for the adp includelets, since the pure xowiki includelets use the "-parameter value" syntax, which is less prone to multiple curly braces. Often, it helps to replace double quotes by braces.

Collapse
Posted by Michael Cordova on
Where is available public-blog includelet?