MDL-42993 Authentication: Added in Trim() for external usernames.
MDL-42993 Authentication: No longer filtering spaces in usernames by default.

Causing issues with external authentication we now only filter out space
characters when extendedusernamechars is set to false causing only
a strict subset of usernames to be valid for Moodle.
MDL-42993 auth: Allow spaces in usernames for external authentication

Only when $CFG->extendedusernamechars is set to true.
Also included 2 trim statements where small issues were found with reading
external usernames in that  were not filtered for trailing whitespaces.
MDL-42993 Authentication: Added in Trim() for external usernames.
MDL-42993 Authentication: No longer filtering spaces in usernames by default.

Causing issues with external authentication we now only filter out space
characters when extendedusernamechars is set to false causing only
a strict subset of usernames to be valid for Moodle.
Merge branch 'MDL-42993-master' of git://github.com/zbdd/moodle into MDL-42993-master

Conflicts:
	config-dist.php
	lib/moodlelib.php