diff --git a/lib/accesslib.php b/lib/accesslib.php
index <HASH>..<HASH> 100755
--- a/lib/accesslib.php
+++ b/lib/accesslib.php
@@ -3924,6 +3924,9 @@ function get_assignable_roles ($context, $field="name") {
             $roles[$r->id] = $r->{$field};
         }
     }
+    foreach ($roles as $roleid => $rolename) {
+        $roles[$roleid] = strip_tags(format_string($rolename, true));
+    }
     return $roles;
 }
Make sure that the role names gets filtered in get_assignable_roles()