Backported url encoding fix