Changeset c29b82d in github


Ignore:
Timestamp:
Dec 20, 2011 3:29:28 AM (17 months ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
Children:
bab0433
Parents:
1886349
Message:

Fix crashes with eAccelerator (#1488256)

Location:
program
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • program/steps/mail/get.inc

    rb6da0b7 rc29b82d  
    66 |                                                                       | 
    77 | This file is part of the Roundcube Webmail client                     | 
    8  | Copyright (C) 2005-2009, The Roundcube Dev Team                       | 
     8 | Copyright (C) 2005-2011, The Roundcube Dev Team                       | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    195195 
    196196 
    197  
    198 /** 
    199  * PHP stream filter to detect html/javascript code in attachments 
    200  */ 
    201 class rcube_content_filter extends php_user_filter 
    202 { 
    203   private $buffer = ''; 
    204   private $cutoff = 2048; 
    205  
    206   function onCreate() 
    207   { 
    208     $this->cutoff = rand(2048, 3027); 
    209     return true; 
    210   } 
    211  
    212   function filter($in, $out, &$consumed, $closing) 
    213   { 
    214     while ($bucket = stream_bucket_make_writeable($in)) { 
    215       $this->buffer .= $bucket->data; 
    216  
    217       // check for evil content and abort 
    218       if (preg_match('/<(script|iframe|object)/i', $this->buffer)) 
    219         return PSFS_ERR_FATAL; 
    220  
    221       // keep buffer small enough 
    222       if (strlen($this->buffer) > 4096) 
    223         $this->buffer = substr($this->buffer, $this->cutoff); 
    224  
    225       $consumed += $bucket->datalen; 
    226       stream_bucket_append($out, $bucket); 
    227     } 
    228  
    229     return PSFS_PASS_ON; 
    230   } 
    231 } 
    232  
Note: See TracChangeset for help on using the changeset viewer.