Fix a few edge cases when parsing URLs and cookies

Real-world cases found out there in the wild.