jira-importer opened a new issue, #962: URL: https://github.com/apache/httpcomponents-core/issues/962
**[Guillaume Castagnino](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=guilc)** opened **[HTTPCORE-313](https://issues.apache.org/jira/browse/HTTPCORE-313?redirect=false)** and commented I parse a broken HTTP response from a server that replies with a crafted Content-Type header: Content-Type: text/html; charset= charset is present, but is empty. When using the EntityUtils.toString method, this triggers an uncaught exception in ContentType.create. Indeed, it calls this: return create(mimeType, charset != null ? Charset.forName(charset) : null); charset is checked against the null value. But the empty string is not checked. Charset.forName("") throws a "java.nio.charset.IllegalCharsetNameException" exception which is not caught whereas Charset.forName("broken") throws a "java.nio.charset.UnsupportedCharsetException" exception, which is correctly handled. So I think that the empty string should be checked and managed like the null, isn't it ? --- **Affects:** 4.2.1 **Backported to:** [4.2.3](https://github.com/apache/httpcomponents-core/milestone/26?closed=1) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
