diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 0d13e0b3c..90fdb8838 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 52211 - avoid unnessary re-coverting content types to US-ASCII, it can cause exceptions on ibm mainframes 53568 - Set shapes anchors in XSSF when reading from existing drawings HSSFOptimiser will now also tidy away un-used cell styles, in addition to duplicate styles 53493 - Fixed memory and temporary file leak in SXSSF diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java index ecf45af54..4d4c9283c 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java @@ -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 '" diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java index 257f4015d..ab2d6aa71 100644 --- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java +++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java @@ -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]);