This again is too complicated and unescapes every url, which is unnecessary. Does attached patch work for you?