0

I'm using HTMLPurifier on an PHP site I'm developing and testing locally with XAMPP on Mac. The app is built using Doctrine2 + Codeigniter.

I am running HTMLPurifier on about 4 text fields on save of a model. Sometimes I receive a No Data Received error message when doing this. Checking the apache logs I see this message:

*** set a breakpoint in malloc_error_break to debug
httpd(60406) malloc: *** error for object 0x2af7070: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
httpd(60412) malloc: *** error for object 0x2ae0004: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
httpd(60412) malloc: *** error for object 0x2af7070: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
[Sun Oct 21 13:13:18 2012] [notice] child pid 60414 exit signal Segmentation fault (11)

If I turn off HTMLPurifier, no error messages are traced.

Here is the code I'm using:

// ContentMedia model
public function purifyHTMLText(){

    $CI =& get_instance();

    $this->imageCredits = $CI->applibrary->doPurify($this->imageCredits);
    $this->contentCopy = $CI->applibrary->doPurify($this->contentCopy);
    $this->extraCredits = $CI->applibrary->doPurify($this->extraCredits);
    $this->authors = $CI->applibrary->doPurify($this->authors);

}

// AppLibrary
public function getHTMLPurifier(){

    if(!isset($htmlPurifier)){

        $CI =& get_instance();
        $CI->load->library('HTMLPurifier');
        $config = \HTMLPurifier_Config::createDefault();
        $config->set('HTML.Allowed', 'a[href],br,b,strong,em');
            $config->set('HTML.DefinitionID', 'mydef');
            $config->set('HTML.DefinitionRev', 1);
            $config->set('Cache.DefinitionImpl', 'Serializer');
            $def = $config->maybeGetRawDefinition('HTML');
        $this->htmlPurifier = new \HTMLPurifier($config);

    }

}

public function doPurify($text){
            $this->getHTMLPurifier();
    return $this->htmlPurifier->purify($text);
}
4

0 回答 0