Merged in bugfix/PMC-196 (pull request #6737)

PMC-196

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Roly
2019-01-04 15:53:45 +00:00
committed by Julio Cesar Laura Avendaño
3 changed files with 27 additions and 3 deletions

View File

@@ -5893,4 +5893,25 @@ class G
$class = isset(self::$adapters[$key]) ? self::$adapters[$key] : $name;
return class_exists($class);
}
/**
* Fix string corrupted related to PMC-336.
* To do, this method should be removed. Related to PMC-336.
*
* @param string $string
* @return string
*/
public static function fixStringCorrupted($string)
{
$string = preg_replace_callback("/iconv\\(\\'UCS\\-4LE\\',\\'UTF\\-8\\',pack\\(\\'V\\', hexdec\\(\\'U[a-f0-9]{4}\\'\\)\\)\\)/", function($result) {
//This looks for the following pattern:
//iconv('UCS-4LE','UTF-8',pack('V', hexdec('U062f')))iconv('UCS-4LE','UTF-8',pack('V', hexdec('U0631')))
//So making this replacement is safe.
$portion = $result[0];
$portion = str_replace("iconv('UCS-4LE','UTF-8',pack('V', hexdec('U", "\u", $portion);
$portion = str_replace("')))", "", $portion);
return $portion;
}, $string);
return $string;
}
}