[
https://issues.apache.org/jira/browse/HTTPCORE-313?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458989#comment-13458989
]
Gary D. Gregory commented on HTTPCORE-313:
------------------------------------------
It seems sensible. What about a string full of white space (space, tab and so
on)?
> ContentType.create(final String mimeType, final String charset) uncaught
> exception when charset == ""
> -----------------------------------------------------------------------------------------------------
>
> Key: HTTPCORE-313
> URL: https://issues.apache.org/jira/browse/HTTPCORE-313
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Components: HttpCore
> Affects Versions: 4.2.1
> Environment: Ubuntu 12.04 LTS with openjdk-7
> Reporter: Guillaume Castagnino
>
> 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 ?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]