Skip to content
  • Nicolas Roeser's avatar
    MDL-64975 moodlelib: fix float formatting if decsep is ~ (tilde) · 76a3cf95
    Nicolas Roeser authored
    Commit 637da99e has introduced changes
    for removing trailing zeroes from the output of function format_float.
    Due to a small omission, the function causes a PHP warning when the
    string decsep is set to a tilde character ('~'). This is rarely the
    case.
    
    The bug lies in using PHP function preg_replace with a string that
    contains external input (in this case, including decsep), but without
    escaping it for PCRE processing.
    
    This commit fixes the function to also support a tilde character in
    string decsep. It also adds tests for having tilde as decimal separator.
    
    Thanks-To:  Jake Dallimore <jake@moodle.com>
    76a3cf95