Trim string to avoid error in Firefox