a11y: Be safe against non-UTF8
The string we're passed here may not be zero-terminated since our text insertion APIs take string + length. So So be safe and copy the text we are interested in if necessary.
Fixes: #6131 (closed)
Edited by Matthias Clasen