tirin 0 Posted September 6, 2016 Hi I have a problem in class.phpmailer.php because the use of /e modifier is deprecated for function preg_replace. The error says that i need change for preg_replace_callback function, but i cant get it ok. Now i have changed the code and delete de e modifier for dont have errors but i dont know the correct way to change the code for using the preg_replace_callback function. Someone can say me how i change this code for use the preg_replace_callback function?? $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); if y change directly the function the page return an error in argument number 2.. $encoded = preg_replace_callback("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); thank you Share this post Link to post Share on other sites
MrPhil 646 Posted September 6, 2016 This might help: http://stackoverflow.com/questions/16367404/how-to-convert-preg-replace-e-to-preg-replace-callback Share this post Link to post Share on other sites
tirin 0 Posted September 6, 2016 Thank you I change my code and at the moment dont returns error when the web send emails. Can you confirm that the change is correcT??? Thank you Sorry for my english case 'phrase': // $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); //$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/", "'='.sprintf('%02X', ord('\\1'))", $encoded); $regex="/([^A-Za-z0-9!*+\/ -])/"; $stuff="'='.sprintf('%02X', ord('\\1'))"; $encoded = preg_replace_callback($regex, function ($match) { return $stuff; }, $encoded); break; case 'comment': // $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); $regex="/([\(\)\"])/"; $stuff="'='.sprintf('%02X', ord('\\1'))"; $encoded= preg_replace_callback($regex, function ($match) { return $stuff; }, $encoded); case 'text': default: // Replace every high ascii, control =, ? and _ characters //TODO using /e (equivalent to eval()) is probably not a good idea // $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', // "'='.sprintf('%02X', ord('\\1'))", $encoded); $regex="/([\000-\011\013\014\016-\037\075\077\137\177-\377])/"; $stuff="'='.sprintf('%02X', ord('\\1'))"; $encoded =preg_replace_callback($regex, function ($match) { return $stuff; }, $encoded); break; } Share this post Link to post Share on other sites
MrPhil 646 Posted September 7, 2016 I suspect it's not correct, but not being all that familiar with the usage of preg_replace_callback(), I can't tell you for sure. I suggest you go back to that page and follow some of the side links for other similar questions and answers and discussion. For instance, you use $match, but where is it set? $stuff is defined outside this section, but is it used within the function? You might feed your code a given input, and see if it comes up with the expected output. Or, if this code is from an older version of osC, you might grab the current (2.3.4BS) version to see what it has been updated to. Share this post Link to post Share on other sites
piernas 125 Posted September 7, 2016 @@tirin here you have the latest github code for this class: https://github.com/PHPMailer/PHPMailer/blob/master/class.phpmailer.php I can't see the line you mention so it may have been already changed. Maybe you can use the current class? Share this post Link to post Share on other sites
piernas 125 Posted September 7, 2016 Line 2903: $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); Looks like that part of the code has ben rewriten. Current version is 5.2.16. Share this post Link to post Share on other sites