legendbox not compatible with 1.6.5

A place to report and discuss bugs - please mention CMSimple-version, server, platform and browser version
svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

legendbox not compatible with 1.6.5

Post by svasti » Mon Feb 02, 2015 11:47 pm

Just got an email from Wolfgang that my site is throwing out strange error messages.

After lots of testing I found:

If you have examples like <strong>{{{</strong>some plugincall<strong>}}}</strong>, which were fine in 1.6.4, your 1.6.5 site will though out error messages even with error reporting disabled.

And legendbox, which calls a plugin inside a plugin, throws out error messages like
Function 40() is not defined!
Plugin call was {{{legendbox('XH_mailform()','Example of a Legendbox','width:40%; background:#eee;border:2px solid #008;border-radius:.5em;float:right; padding:1em;margin:0 0 1em 1em;','font-weight:bold;color:#008;');}}}

Code: Select all

function legendbox($plugin, $legend='', $boxcss='', $legendcss='')
{
    $boxcss = $boxcss? ' style="'.$boxcss.'"':'';
    $legendcss = $legendcss? ' style="'.$legendcss.'"':'';

    return "\n\n<!-- L E G E N D B O X   S T A R T -->\n"
        . '<fieldset class="legendbox"'. $boxcss . '">'
        . '<legend'.$legendcss.'>'. $legend. '</legend>'
        . evaluate_scripting('{{{PLUGIN:'.$plugin.';}}}')
        . '</fieldset>'
        . "\n<!-- L E G E N D B O X   E N D -->\n\n";
}

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: legendbox not compatible with 1.6.5

Post by svasti » Tue Feb 03, 2015 1:34 pm

After some experimentation I found that legendbox works under a certain condition in 1.6.5:
legendbox gets 4 arguments: (1) the plugincall in the box, (2) the legend caption, (3) the box css, (4) the legend css

Both css data arguments must not have a first css entry without space after ":", e.g. width:200px; such an entry results in an error message.
However adding a space makes legendbox work again, e.g. width: 200px;. Funny is that any following css entries may be written without space.

All right, I'll add a note on the download page concerning 1.6.5 and make the legendbox again downloadable

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: legendbox not compatible with 1.6.5

Post by cmb » Tue Feb 03, 2015 2:21 pm

svasti wrote:And legendbox, which calls a plugin inside a plugin, throws out error messages like
Function 40() is not defined!
Plugin call was {{{legendbox('XH_mailform()','Example of a Legendbox','width:40%; background:#eee;border:2px solid #008;border-radius:.5em;float:right; padding:1em;margin:0 0 1em 1em;','font-weight:bold;color:#008;');}}}
That is caused by making the parentheses for the plugin call optional. In XH 1.6.5 everything up to and including the "width:" is understood as comment; the "40" is understood as function name, what causes the error message. In XH 1.6.4 there is no comment detected, because there is no opening bracket, so "legendbox" is the function name, as desired. However, even in XH 1.6.4 the following would fail:

Code: Select all

{{{legendbox('XH_mailform()', 'Example of a Legendbox', 'background:url(bg.jpg)');}}}
The cleanest solution to avoid any such problems would be to put PLUGIN: (or any other comment) at the beginning, if there is a colon contained in the arguments of the plugin call, e.g.:

Code: Select all

{{{PLUGIN:legendbox('XH_mailform()', 'Example of a Legendbox', 'background:url(bg.jpg)');}}}
svasti wrote:If you have examples like <strong>{{{</strong>some plugincall<strong>}}}</strong>, which were fine in 1.6.4, your 1.6.5 site will though out error messages even with error reporting disabled.
I have not been able to reproduce this with

Code: Select all

<strong>{{{</strong>XH_mailform<strong>}}}</strong>
Can you please give a concrete example so I can reproduce the issue.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: legendbox not compatible with 1.6.5

Post by svasti » Tue Feb 03, 2015 4:01 pm

cmb wrote:Can you please give a concrete example so I can reproduce the issue.
It seems I had in the text this line as example how to use legendbox in 1.5.4

Code: Select all

<strong>{{{PLUGIN:legendbox(usw., ...):}}}</strong>
and this worked in 1.6.4, but not in 1.6.5. Funny that it even worked in 1.6.4. If you have it in 1.6.5 on somewhere on some page and start the search on another page, XH will produce:
XH 1.6.5 + funny example wrote:Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /home/www/web35/html/cmsimple/cmsimple/functions.php(282) : eval()'d code on line 1
Anyhow this has been changed and now the site is working all right again.

Concerning Legendbox, I am now explaining in detail the working of the colon on the legendbox download page, so I think it's OK as it is. Users have to be aware to either start with {{{PLUGIN: or {{{ADDON: or just add a space after the first colon of the css.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: legendbox not compatible with 1.6.5

Post by cmb » Tue Feb 03, 2015 5:10 pm

svasti wrote:It seems I had in the text this line as example how to use legendbox in 1.5.4

Code: Select all

<strong>{{{PLUGIN:legendbox(usw., ...):}}}</strong>
and this worked in 1.6.4, but not in 1.6.5.
This would not be evaluated in XH 1.6.4, because of the missing semicolon at the end (there's a colon instead). In XH 1.6.5 it would be evaluated, though, because the trailing semicolon is optional now. However, the evaluation would result in a PHP parse error: "syntax error, unexpected ','".
svasti wrote:Concerning Legendbox, I am now explaining in detail the working of the colon on the legendbox download page, so I think it's OK as it is. Users have to be aware to either start with {{{PLUGIN: or {{{ADDON: or just add a space after the first colon of the css.
ACK
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: legendbox not compatible with 1.6.5

Post by svasti » Wed Feb 04, 2015 11:14 am

Now thinking about the decision to allow any comment before a colon in the plugin call, I really doubt that anybody uses this. It's simply too verbose, and the general tendency goes towards less unnecessary stuff.

So it may have been a mistake after all, it may have been better to allow only PLUGIN: for compatibility reasons and nothing else -- as there was nothing else allowed before. In this case the legendbox issue wouldn't have occurred. Now we have introduced an unnessessary new possibility which probably nobody is using but which however requires to look out for sudden incompatibilities.

What about changing the regex in evaluate_plugincall to $re = '/{{{(?:[^PLUGIN:]+:)?([a-z_0-9]+)\s*\(?(.*?)\)?;?}}}/iu';

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: legendbox not compatible with 1.6.5

Post by cmb » Wed Feb 04, 2015 12:00 pm

svasti wrote:Now thinking about the decision to allow any comment before a colon in the plugin call, I really doubt that anybody uses this. It's simply too verbose, and the general tendency goes towards less unnecessary stuff.
Well, there has been some discussion regarding this decision. I'm not against reconsidering the issue, though.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: legendbox not compatible with 1.6.5

Post by svasti » Wed Feb 04, 2015 2:16 pm

cmb wrote:I'm not against reconsidering the issue, though.
Should we put it on the roadmap 1.6.6 or 1.7?
cmb wrote:Well, there has been some discussion regarding this decision.
It seems at that time that nobody was aware that a plugin could have a colon in its arguments.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: legendbox not compatible with 1.6.5

Post by cmb » Wed Feb 04, 2015 2:29 pm

svasti wrote:Should we put it on the roadmap 1.6.6 or 1.7?
If in doubt, I suggest to put it to vote for 1.6.6. We can always vote "later".
Christoph M. Becker – Plugins for CMSimple_XH

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: legendbox not compatible with 1.6.5

Post by Holger » Wed Feb 04, 2015 2:38 pm

I was the one voted "never" on that topic for 1.6.5.

IMO we should not try to make everything as much foolproof for inexperienced users as possible. I'm fine with one (and only one) clear and correct syntax for a plugin-call. And if something goes wrong, a short error message should be enough.

Post Reply