Author: markt
Date: Tue Mar 19 10:07:32 2013
New Revision: 1458200

URL: http://svn.apache.org/r1458200
Log:
Updates after reviewing diff between Tomcat and Commons versions of Fileupload

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/Base64Decoder.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/QuotedPrintableDecoder.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java?rev=1458200&r1=1458199&r2=1458200&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java Tue 
Mar 19 10:07:32 2013
@@ -197,7 +197,7 @@ public interface FileItem extends Serial
      * be used for storing the contents of the file.
      *
      * @return An {@link java.io.OutputStream OutputStream} that can be used
-     *         for storing the contents of the file.
+     *         for storing the contensts of the file.
      *
      * @throws IOException if an error occurs.
      */

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/Base64Decoder.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/Base64Decoder.java?rev=1458200&r1=1458199&r2=1458200&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/Base64Decoder.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/Base64Decoder.java
 Tue Mar 19 10:07:32 2013
@@ -35,8 +35,7 @@ final class Base64Decoder {
         (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 
'f', (byte) 'g',
         (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 
'm', (byte) 'n',
         (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 
't', (byte) 'u',
-        (byte) 'v',
-        (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z',
+        (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z',
         (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) 
'5', (byte) '6',
         (byte) '7', (byte) '8', (byte) '9',
         (byte) '+', (byte) '/'
@@ -69,9 +68,10 @@ final class Base64Decoder {
 
     /**
      * Checks if the input char must be skipped from the decode.
+     * The method skips whitespace characters LF, CR, horizontal tab and space.
      *
-     * @param c the char has to be checked.
-     * @return true, if the input char has to be checked, false otherwise.
+     * @param c the char to be checked.
+     * @return true, if the input char has to be skipped, false otherwise.
      */
     private static boolean ignore(char c) {
         return (c == '\n' || c == '\r' || c == '\t' || c == ' ');
@@ -81,6 +81,11 @@ final class Base64Decoder {
      * Decode the base 64 encoded byte data writing it to the given output 
stream,
      * whitespace characters will be ignored.
      *
+     * @param data the buffer containing the Base64-encoded data
+     * @param off the start offset (zero-based)
+     * @param length the number of bytes to convert
+     * @param out the output stream to hold the decoded bytes
+     *
      * @return the number of bytes produced.
      */
     public static int decode(byte[] data, int off, int length, OutputStream 
out) throws IOException {

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java?rev=1458200&r1=1458199&r2=1458200&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java
 Tue Mar 19 10:07:32 2013
@@ -67,14 +67,14 @@ public final class MimeUtility {
 
     /**
      * Decode a string of text obtained from a mail header into
-     * it's proper form.  The text generally will consist of a
+     * its proper form.  The text generally will consist of a
      * string of tokens, some of which may be encoded using
      * base64 encoding.
      *
      * @param text   The text to decode.
      *
-     * @return The decoded test string.
-     * @throws UnsupportedEncodingException
+     * @return The decoded text string.
+     * @throws UnsupportedEncodingException if the detected encoding in the 
input text is not supported.
      */
     public static String decodeText(String text) throws 
UnsupportedEncodingException {
         // if the text contains any encoded tokens, those tokens will be 
marked with "=?".  If the

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/QuotedPrintableDecoder.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/QuotedPrintableDecoder.java?rev=1458200&r1=1458199&r2=1458200&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/QuotedPrintableDecoder.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/QuotedPrintableDecoder.java
 Tue Mar 19 10:07:32 2013
@@ -33,9 +33,10 @@ final class QuotedPrintableDecoder {
     };
 
     /**
-     * The default number of byte shift for decode.
+     * The shift value required to create the upper nibble
+     * from the first of 2 byte values converted from ascii hex.
      */
-    private static final int OUT_SHIFT = 4;
+    private static final int UPPER_NIBBLE_SHIFT = Byte.SIZE / 2;
 
     /**
      * Set up the decoding table; this is indexed by a byte converted to an 
int,
@@ -59,7 +60,7 @@ final class QuotedPrintableDecoder {
     }
 
     /**
-     * Decode the unencoded byte data writing it to the given output stream.
+     * Decode the encoded byte data writing it to the given output stream.
      *
      * @param data   The array of byte data to decode.
      * @param off    Starting offset within the array.
@@ -100,7 +101,7 @@ final class QuotedPrintableDecoder {
                     // this is a hex pair we need to convert back to a single 
byte.
                     byte c1 = DECODING_TABLE[b1];
                     byte c2 = DECODING_TABLE[b2];
-                    out.write((c1 << OUT_SHIFT) | c2);
+                    out.write((c1 << UPPER_NIBBLE_SHIFT) | c2);
                     // 3 bytes in, one byte out
                     bytesWritten++;
                 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to