Doc #18538 [Com]: Fatal Error w/ Mail_mimedecode 1.5.5 and php 5.2.17

From: Date: Wed, 21 Feb 2018 19:44:26 +0000
Subject: Doc #18538 [Com]: Fatal Error w/ Mail_mimedecode 1.5.5 and php 5.2.17
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to [email protected] to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=18538&edit=1

 ID:               18538
 Comment by:       slgundam at gmail dot com
 Reported By:      afduggan at gmail dot com
 Summary:          Fatal Error w/ Mail_mimedecode 1.5.5 and php 5.2.17
 Status:           Feedback
 Type:             Documentation Problem
 Package:          Mail_mimeDecode
 Operating System: CentOS 5.6
 Package Version:  1.5.5
 PHP Version:      5.2.12
 Roadmap Versions: 
 New Comment:

PHP 7.2 deprecated the create_function call so here the fix as
implemented from the previous source

function _quotedPrintableDecode($input)
{
    // Remove soft line breaks
    $input = preg_replace("/=\r?\n/", '', $input);

    // Replace encoded characters

// ERP-modification: Deprecated in PHP 7.2
//    $cb = create_function('$matches',  ' return
chr(hexdec($matches[0]));');

//    $input = preg_replace_callback( '/=([a-f0-9]{2})/i', $cb,
$input);
    $input = preg_replace_callback( '/=([a-f0-9]{2})/i', function(
$matches )
    {
    	return( chr( hexdec( $matches[ 0 ] ) ) );
    }, $input );

    return $input;
}


Previous Comments:
------------------------------------------------------------------------

[2016-08-27 23:01:18] scott99

here's the fixed function:

function _quotedPrintableDecode($input)
   {
       // Remove soft line breaks
       $input = preg_replace("/=\r?\n/", '', $input);
       // Replace encoded characters
		// ERP-modification: PHP7 deprecated the /e PCRE modifier.
//		$input = preg_replace('/=([a-f0-9]{2})/ie', 
"chr(hexdec('\\1'))", $input);
		$input = preg_replace_callback('/=([a-f0-9]{2})/i', function 
($matches) { return chr(hexdec($matches[1])); }, $input);
       return $input;
   }

------------------------------------------------------------------------

[2015-07-21 16:12:20] bchris999

Same problem here with PHP 5.3.3 on CentOS 5.6.

The documentation only mentions and shows examples of calling getXML
statically.

$decoder->getXML(); doesn't work, however
$decoder->getXML($decodeoutput); does work!

------------------------------------------------------------------------

[2011-05-15 12:40:02] doconnor

-Status: Open
+Status: Feedback
-Type:   Bug
+Type:   Documentation Problem
Alex, if you think about it; you already have an instantiated $decoder
variable 
containing a Mail_mimeDecode object - why would you need to call a
static method?

I'll agree that perhaps there is a doc bug or it might need more
examples - where did 
you expect to find usage examples &  didn't?.

------------------------------------------------------------------------

[2011-05-15 04:37:07] aldug

Description:
------------
Calling the getXML () method statically, the only way I can find
documentation to call it, throws a fatal error.

php 5.2.17



Test script:
---------------
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;

$decoder = new Mail_mimeDecode (file_get_contents ($filename));
$structure = $decoder->decode ($params);
$xml    = Mail_mimeDecode::getXML($structure);

Expected result:
----------------
To get an xml document

Actual result:
--------------
Fatal error: Using $this when not in object context in
/usr/local/php5/lib/php/Mail/mimeDecode.php on line 486

------------------------------------------------------------------------


-- 
Edit this bug report at https://pear.php.net/bugs/bug.php?id=18538&edit=1


Thread (1 message)

« previous php.pear.bugs (#11415) next »