Fix bug #1163572

RTF input modifications.
Is this Ok for you?
I will send a pull request for trim once all the modifications have been done.