This commit is contained in:
Roly Rudy Gutierrez Pinto
2019-01-03 14:22:58 -04:00
parent 7f6155702f
commit a4b1eac7b9
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; $class = isset(self::$adapters[$key]) ? self::$adapters[$key] : $name;
return class_exists($class); 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;
}
} }

View File

@@ -65,6 +65,8 @@ class PmDynaform
} }
$this->record["DYN_CONTENT"] = G::json_encode($json); $this->record["DYN_CONTENT"] = G::json_encode($json);
} }
//to do, this line should be removed. Related to PMC-196.
$this->record['DYN_CONTENT'] = G::fixStringCorrupted($this->record['DYN_CONTENT']);
} }
public function getDynaformTitle($idDynaform) public function getDynaformTitle($idDynaform)

View File

@@ -966,9 +966,10 @@ class DynaForm
if ($record['DYN_VERSION'] === 0) { if ($record['DYN_VERSION'] === 0) {
$record['DYN_VERSION'] = 1; $record['DYN_VERSION'] = 1;
} }
//to do, this line should be removed. Related to PMC-196.
$record['DYN_CONTENT'] = G::fixStringCorrupted($record['DYN_CONTENT']);
$record['DYN_CONTENT'] = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) { $record['DYN_CONTENT'] = preg_replace_callback("/\\\\u([a-f0-9]{4})/", function ($m) {
return "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$m[1]')))"; return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec('U' . $m[1])));
}, $record['DYN_CONTENT']); }, $record['DYN_CONTENT']);
return array( return array(
@@ -977,7 +978,7 @@ class DynaForm
$this->getFieldNameByFormatFieldName('DYN_DESCRIPTION') => $record['DYN_DESCRIPTION'] . '', $this->getFieldNameByFormatFieldName('DYN_DESCRIPTION') => $record['DYN_DESCRIPTION'] . '',
$this->getFieldNameByFormatFieldName('DYN_TYPE') => $record['DYN_TYPE'] . '', $this->getFieldNameByFormatFieldName('DYN_TYPE') => $record['DYN_TYPE'] . '',
$this->getFieldNameByFormatFieldName('DYN_CONTENT') => $record['DYN_CONTENT'] . '', $this->getFieldNameByFormatFieldName('DYN_CONTENT') => $record['DYN_CONTENT'] . '',
$this->getFieldNameByFormatFieldName('DYN_VERSION') => (int)$record['DYN_VERSION'], $this->getFieldNameByFormatFieldName('DYN_VERSION') => (int) $record['DYN_VERSION'],
$this->getFieldNameByFormatFieldName('DYN_UPDATE_DATE') => $record['DYN_UPDATE_DATE'] $this->getFieldNameByFormatFieldName('DYN_UPDATE_DATE') => $record['DYN_UPDATE_DATE']
); );
} catch (\Exception $e) { } catch (\Exception $e) {