Changeset a366a32 in github


Ignore:
Timestamp:
Jul 13, 2009 2:52:15 PM (4 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
d5515f6
Parents:
c6514e0
Message:

Prevent from endless loops in render_page hook

Location:
program/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_plugin_api.php

    r8448fca ra366a32  
    4040  private $template_contents = array(); 
    4141   
    42   private  $required_plugins = array('filesystem_attachments'); 
     42  private $required_plugins = array('filesystem_attachments'); 
     43  private $active_hook = false; 
    4344 
    4445  /** 
     
    180181  { 
    181182    $args += array('abort' => false); 
     183    $this->active_hook = $hook; 
    182184     
    183185    foreach ((array)$this->handlers[$hook] as $callback) { 
     
    190192    } 
    191193     
     194    $this->active_hook = false; 
    192195    return $args; 
    193196  } 
     
    258261  } 
    259262   
     263   
     264  /** 
     265   * Check if a plugin hook is currently processing. 
     266   * Mainly used to prevent loops and recursion. 
     267   * 
     268   * @param string Hook to check (optional) 
     269   * @return boolean True if any/the given hook is currently processed, otherwise false 
     270   */ 
     271  public function is_processing($hook = null) 
     272  { 
     273    return $this->active_hook && (!$hook || $this->active_hook == $hook); 
     274  } 
     275   
    260276  /** 
    261277   * Include a plugin script file in the current HTML page 
  • program/include/rcube_template.php

    rc6514e0 ra366a32  
    288288    { 
    289289        if ($templ != 'iframe') { 
     290            // prevent from endless loops 
     291            if ($this->app->plugins->is_processing('render_page')) { 
     292                raise_error(array('code' => 505, 'type' => 'php', 'message' => 'Recursion alert: ignoring output->send()'), true, false); 
     293                return; 
     294            } 
    290295            $this->parse($templ, false); 
    291296        } 
Note: See TracChangeset for help on using the changeset viewer.