mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Use preg_replace_callback over preg_replace with e modifier
This commit is contained in:
parent
e4cb25b831
commit
c56a80d6ce
@ -60,20 +60,25 @@ class HTTP {
|
||||
if(!is_numeric($tag)) $tagPrefix = "$tag ";
|
||||
else $tagPrefix = "";
|
||||
|
||||
$regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *\")([^\"]*)(\")/ie";
|
||||
$regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *')([^']*)(')/ie";
|
||||
$regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *)([^\"' ]*)( )/ie";
|
||||
$regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *\")([^\"]*)(\")/i";
|
||||
$regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *')([^']*)(')/i";
|
||||
$regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *)([^\"' ]*)( )/i";
|
||||
}
|
||||
$regExps[] = '/(background-image:[^;]*url *\()([^)]+)(\))/ie';
|
||||
$regExps[] = '/(background:[^;]*url *\()([^)]+)(\))/ie';
|
||||
$regExps[] = '/(list-style-image:[^;]*url *\()([^)]+)(\))/ie';
|
||||
$regExps[] = '/(list-style:[^;]*url *\()([^)]+)(\))/ie';
|
||||
$regExps[] = '/(background-image:[^;]*url *\()([^)]+)(\))/i';
|
||||
$regExps[] = '/(background:[^;]*url *\()([^)]+)(\))/i';
|
||||
$regExps[] = '/(list-style-image:[^;]*url *\()([^)]+)(\))/i';
|
||||
$regExps[] = '/(list-style:[^;]*url *\()([^)]+)(\))/i';
|
||||
|
||||
// Make
|
||||
$code = 'stripslashes("$1") . (' . str_replace('$URL', 'stripslashes("$2")', $code) . ') . stripslashes("$3")';
|
||||
|
||||
$callback = function($matches) use($code) {
|
||||
return
|
||||
stripslashes($matches[1]) .
|
||||
str_replace('$URL', stripslashes($matches[2]), $code) .
|
||||
stripslashes($matches[3]);
|
||||
};
|
||||
|
||||
foreach($regExps as $regExp) {
|
||||
$content = preg_replace($regExp, $code, $content);
|
||||
$content = preg_replace_callback($regExp, $callback, $content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
@ -244,9 +244,12 @@ class Convert {
|
||||
|
||||
// Expand hyperlinks
|
||||
if(!$preserveLinks && !$config['PreserveLinks']) {
|
||||
$data = preg_replace('/<a[^>]*href\s*=\s*"([^"]*)">(.*?)<\/a>/ie', "Convert::html2raw('\\2').'[\\1]'",
|
||||
$data);
|
||||
$data = preg_replace('/<a[^>]*href\s*=\s*([^ ]*)>(.*?)<\/a>/ie', "Convert::html2raw('\\2').'[\\1]'", $data);
|
||||
$data = preg_replace_callback('/<a[^>]*href\s*=\s*"([^"]*)">(.*?)<\/a>/i', function($matches) {
|
||||
return Convert::html2raw($matches[2]) . "[$matches[1]]";
|
||||
}, $data);
|
||||
$data = preg_replace_callback('/<a[^>]*href\s*=\s*([^ ]*)>(.*?)<\/a>/i', function($matches) {
|
||||
return Convert::html2raw($matches[2]) . "[$matches[1]]";
|
||||
}, $data);
|
||||
}
|
||||
|
||||
// Replace images with their alt tags
|
||||
|
@ -368,7 +368,9 @@ function encodeFileForEmail($file, $destFileName = false, $disposition = NULL, $
|
||||
function QuotedPrintable_encode($quotprint) {
|
||||
$quotprint = (string)str_replace('\r\n',chr(13).chr(10),$quotprint);
|
||||
$quotprint = (string)str_replace('\n', chr(13).chr(10),$quotprint);
|
||||
$quotprint = (string)preg_replace("~([\x01-\x1F\x3D\x7F-\xFF])~e", "sprintf('=%02X', ord('\\1'))", $quotprint);
|
||||
$quotprint = (string)preg_replace_callback("~([\x01-\x1F\x3D\x7F-\xFF])~e", function($matches) {
|
||||
return sprintf('=%02X', ord($matches[1]));
|
||||
}, $quotprint);
|
||||
//$quotprint = (string)str_replace('\=0D=0A',"=0D=0A",$quotprint);
|
||||
$quotprint = (string)str_replace('=0D=0A',"\n",$quotprint);
|
||||
$quotprint = (string)str_replace('=0A=0D',"\n",$quotprint);
|
||||
|
Loading…
Reference in New Issue
Block a user