Author: yegor
Date: Thu Oct  4 11:52:20 2012
New Revision: 1394001

URL: http://svn.apache.org/viewvc?rev=1394001&view=rev
Log:
Bugzilla 52211 - avoid unnessary re-coverting content types to US-ASCII, it can 
cause exceptions on ibm mainframes

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

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1394001&r1=1394000&r2=1394001&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Oct  4 11:52:20 
2012
@@ -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>

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java?rev=1394001&r1=1394000&r2=1394001&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java 
(original)
+++ 
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java 
Thu Oct  4 11:52:20 2012
@@ -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 '"

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java?rev=1394001&r1=1394000&r2=1394001&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java 
Thu Oct  4 11:52:20 2012
@@ -85,7 +85,9 @@ public final class TestContentType exten
         */
        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]);



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to