Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid calling String#strip on invalid Strings
Use case: some servers have been known to serve files with Content-Types like “video/mp4; charset=utf-8”, which HTTParty dutifully tells ruby is a UTF-8 string. However, before the Parser can decide that MP4 is not a format it is capable of parsing, the response body is tested for emptiness … after whitespace is stripped. Since the String isn’t actually a valid UTF-8 String, this raises an ArgumentError. This patch fixes that error by avoiding the call on Strings that are not validly encoded.
- Loading branch information