Fixed #20296 -- allow lazy strings to be used with mark_safe().

This was supposed to be fixed after 2ee447fb5f8974b432d3dd421af9a242215aea44
but that commit just worked around the issue (and introduced
some regressions in some corner cases).

Thanks to trac user nealtodd for the initial report.