Shortcode Recursion Bug
-
Hey!
Just a friendly developer reviewing the code here π
I think I found a recursion issue (I’ll be honest, I haven’t installed it just yet). It looks like you have some code in place to prevent the same shortcode from running, but I don’t see anything in place for preventing multi-step recursion. Also, I think the code that’s there would fail to save it after rendering a different sub-shortcode.
More specifically, here’s the code I’m seeing:
// Prevent same shortcode nested loop
if( self::$current_shortcode == $shortcode[ 'name' ] ){
return '';
}
self::$current_shortcode = $shortcode[ 'name' ];
...
self::$current_shortcode = false;
return $sc_content;You probably actually want to make
self::$current_shortcodean array that you push to/pop from, and then do anin_array()check, rather than using a single value. Otherwise, if shortcode A contains B, and shortcode B contains A, this wouldn’t catch the recursion. The= falsehere also fails to restore the previous value. So, if shortcode A contains shortcode B followed by shortcode A,self::$current_shortcodeisfalseby the time the nested A is reached.Thanks for your work though! I’ll probably install this soon! (Albeit, I’ll just be careful with recursive shortcodes π )
You must be logged in to reply to this topic.