Htmlawed causing a fatal error on PHP 5.5.3 - preg_replace(): The /e modifier is deprecated
Hello,
I'm having troubles with Vanilla Forums 2.1b2. For some reason, when I view a discussion on the forum as a guest (not as a logged in user), it gives me a "Something has gone wrong" error, and when enabling debug in the config, it gives me this screen about a fatal error: https://gist.github.com/as-com/8185872#file-error1
I have tried to fix it by replacing line 382 with
$t = str_replace( // PHP 5.5 preg_replace_callback style array("\t", "\r", "\n", ' '), '', preg_replace_callback( '/"(?>(`.|[^"])*)"/sme', function($m) { return substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", '`"'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\""), $m[0]), 1, -1); }, trim($t)));
but then it prints out another error: https://gist.github.com/as-com/8185872#file-error2
Now I'm completely confused about how to fix this. Is there a way to fix it, or am I doing_it_wrong()
?
Best Answers
-
Shadowdare MVP
Please try removing the /e modifier from the first preg_replace_callback argument:
'/"(?>(`.|[^"])*)"/sme'
To:
'/"(?>(`.|[^"])*)"/sm'
Add Pages to Vanilla with the Basic Pages app
8 -
vrijvlinder MVP
@Shadowdare This is what was done in Joomla for the same problem, notice all the e in m is removed too, Possibly this is something they could change in the source for future update of 2.1 . I have seen this more and more often since php 5.5.
It would be appreciated if @UnderDog could mark this as Solution for others to find .
// Convert decimal
//$source = preg_replace('/&#(\d+);/me', "utf8_encode(chr(\1))", $source);
// decimal notationto
$source = preg_replace_callback('/&#(\d+);/m', function($m){return utf8_encode(chr($m[1]));}, $source);
// decimal notation// Convert hex
//$source = preg_replace('/&#x([a-f0-9]+);/mei', "utf8_encode(chr(0x\1))", $source);to
// hex notation
$source = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){return utf8_encode(chr('0x'.$m[1]));}, $source);// hex notation
7
Answers
Can you please try this using php version 5.4 ?
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Please try removing the /e modifier from the first preg_replace_callback argument:
To:
Add Pages to Vanilla with the Basic Pages app
@Shadowdare This is what was done in Joomla for the same problem, notice all the e in m is removed too, Possibly this is something they could change in the source for future update of 2.1 . I have seen this more and more often since php 5.5.
It would be appreciated if @UnderDog could mark this as Solution for others to find .
// Convert decimal
//$source = preg_replace('/&#(\d+);/me', "utf8_encode(chr(\1))", $source);
// decimal notation
to
$source = preg_replace_callback('/&#(\d+);/m', function($m){return utf8_encode(chr($m[1]));}, $source);
// decimal notation
// Convert hex
//$source = preg_replace('/&#x([a-f0-9]+);/mei', "utf8_encode(chr(0x\1))", $source);
to
// hex notation
$source = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){return utf8_encode(chr('0x'.$m[1]));}, $source);
// hex notation
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌