tirin Posted September 6, 2016 Share 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 Link to comment Share on other sites More sharing options...
MrPhil Posted September 6, 2016 Share Posted September 6, 2016 This might help: http://stackoverflow.com/questions/16367404/how-to-convert-preg-replace-e-to-preg-replace-callback Link to comment Share on other sites More sharing options...
tirin Posted September 6, 2016 Author Share 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; } Link to comment Share on other sites More sharing options...
MrPhil Posted September 7, 2016 Share 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. Link to comment Share on other sites More sharing options...
piernas Posted September 7, 2016 Share 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? Link to comment Share on other sites More sharing options...
piernas Posted September 7, 2016 Share 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.