Fix: Let util_url_escape() handle NULL parameter.
This let util_url_escape() handle NULL passed as parameter. In case the parameter is NULL it will also return NULL. This patch also does some cleanup of the code such as migration away from int and thus avoiding future failtures. This is a re-apply of 3baa4e46 as git refuses to cherry-pick.