Instead of using remove(), we should be use stripWhiteSpace here, to not only correctly remove whitespace at the start of text but also at the end.
Created attachment 178258 [details] Patch
Comment on attachment 178258 [details] Patch LGTM.
Comment on attachment 178258 [details] Patch Clearing flags on attachment: 178258 Committed r136981: <http://trac.webkit.org/changeset/136981>
All reviewed patches have been landed. Closing bug.