MDL-67316 ldap: Pass correct hex chars to hexdec()
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 20 Nov 2019 16:45:32 +0000 (17:45 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 24 Apr 2020 13:56:38 +0000 (15:56 +0200)
Before php74 they were silently discarded, now they
show a deprecation message.

lib/ldaplib.php

index 78923c7..2da0f15 100644 (file)
@@ -448,7 +448,7 @@ function ldap_stripslashes($text) {
     $text = preg_replace_callback($quoted,
                                   function ($match) use ($specialchars) {
                                       if (ctype_xdigit(ltrim($match[1], '\\'))) {
-                                          return chr(hexdec($match[1]));
+                                          return chr(hexdec(ltrim($match[1], '\\')));
                                       } else {
                                           return str_replace($specialchars[LDAP_DN_SPECIAL_CHARS_QUOTED_ALPHA],
                                                              $specialchars[LDAP_DN_SPECIAL_CHARS],