diff --git a/libraries/advisor.class.php b/libraries/advisor.class.php index 75c8a8d9b8..d6ea9035b3 100644 --- a/libraries/advisor.class.php +++ b/libraries/advisor.class.php @@ -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']);