Bugzilla 52211 - avoid unnessary re-coverting content types to US-ASCII, it can cause exceptions on ibm mainframes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1394001 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2012-10-04 11:52:20 +00:00
parent 7432358cf7
commit 8cd113ba9e
3 changed files with 5 additions and 11 deletions

View File

@ -34,6 +34,7 @@
<changes>
<release version="3.9-beta1" date="2012-??-??">
<action dev="poi-developers" type="fix">52211 - avoid unnessary re-coverting content types to US-ASCII, it can cause exceptions on ibm mainframes</action>
<action dev="poi-developers" type="fix">53568 - Set shapes anchors in XSSF when reading from existing drawings</action>
<action dev="poi-developers" type="add">HSSFOptimiser will now also tidy away un-used cell styles, in addition to duplicate styles</action>
<action dev="poi-developers" type="fix">53493 - Fixed memory and temporary file leak in SXSSF </action>

View File

@ -134,16 +134,7 @@ public final class ContentType {
* If the specified content type is not valid with RFC 2616.
*/
public ContentType(String contentType) throws InvalidFormatException {
// Conversion en US-ASCII
String contentTypeASCII = null;
try {
contentTypeASCII = new String(contentType.getBytes(), "US-ASCII");
} catch (UnsupportedEncodingException e) {
throw new InvalidFormatException(
"The specified content type is not an ASCII value.");
}
Matcher mMediaType = patternMediaType.matcher(contentTypeASCII);
Matcher mMediaType = patternMediaType.matcher(contentType);
if (!mMediaType.matches())
throw new InvalidFormatException(
"The specified content type '"

View File

@ -85,7 +85,9 @@ public final class TestContentType extends TestCase {
*/
public void testContentTypeParameterFailure() {
String[] contentTypesToTest = new String[] { "mail/toto;titi=tata",
"text/xml;a=b;c=d", "mail/toto;\"titi=tata\"" };
"text/xml;a=b;c=d", "mail/toto;\"titi=tata\"",
"text/\u0080" // characters above ASCII are not allowed
};
for (int i = 0; i < contentTypesToTest.length; ++i) {
try {
new ContentType(contentTypesToTest[i]);