Jump to content

mds_template() crashes on false


Kaya

Recommended Posts

The mds_template() function crashes on any value that evaluates to false:

 

Example:

[spoiler]
content:

Template values:<br/>
0:[[zero]]<br/>
'0':[[zerostring]]<br/>
'':[[mptystring]]<br/>
null:[[null]]<br/>
FALSE:[[false]]<br/>
' ':[[space]]<br/>

 
code:

(locations 1_-1x2_1)
@tpl['zero'] = 0;
@tpl['zerostring'] = '0';
@tpl['mptystring'] = '';
@tpl['null'] = null;
@tpl['false'] = FALSE;
@tpl['space'] = ' ';
mds_template(@content[0], @tpl);

 
output:
 

#Could not find matching value for template keyword '[[zero]]'.
#Could not find matching value for template keyword '[[zerostring]]'.
#Could not find matching value for template keyword '[[mptystring]]'.
#Could not find matching value for template keyword '[[null]]'.
#Could not find matching value for template keyword '[[false]]'.


[/spoiler]

 

It seems like there is an isset() missing in the template code.

 

One way to work around this is by appending a space to each value to make sure they are no longer empty. (As extra spaces are normally ignored in HTML)

Link to comment
Share on other sites

  • 5 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Forum Statistics

    17.5k
    Total Topics
    182.5k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...