Factor out percent escaping
This commit is contained in:
parent
621d179573
commit
9be2507a58
@ -81,6 +81,14 @@ class Advisor
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes percent string to be used in format string.
|
||||
*/
|
||||
function escapePercent($str)
|
||||
{
|
||||
return preg_replace('/%( |,|\.|$)/','%%\1', $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits justification to text and formula.
|
||||
*/
|
||||
@ -88,7 +96,7 @@ class Advisor
|
||||
{
|
||||
$jst = preg_split('/\s*\|\s*/', $rule['justification'], 2);
|
||||
if (count($jst) > 1) {
|
||||
$jst[0] = preg_replace('/%( |,|\.|$)/','%%\1',$jst[0]);
|
||||
$jst[0] = Advisor::escapePercent($jst[0]);
|
||||
return array($jst[0], $jst[1]);
|
||||
}
|
||||
return array($rule['justification']);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user