]> source.dussan.org Git - poi.git/commitdiff
Bugzilla 52211 - avoid unnessary re-coverting content types to US-ASCII, it can cause...
authorYegor Kozlov <yegor@apache.org>
Thu, 4 Oct 2012 11:52:20 +0000 (11:52 +0000)
committerYegor Kozlov <yegor@apache.org>
Thu, 4 Oct 2012 11:52:20 +0000 (11:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1394001 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java
src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java

index 0d13e0b3c438db60b00560c7d3b768a5d519dac7..90fdb8838c1fc57becec987a1d4489d6539814d4 100644 (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>
index ecf45af5497ea72e3c5ca4506586076fae953c2a..4d4c9283c2b7d156926bdc8f98affdf3ccf92090 100644 (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 '"
index 257f4015de3501c24962f4a2cac7f4c37d8f426b..ab2d6aa7162289e4e53473d497d6bf372a52ade0 100644 (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]);