eolstyle
Also fix & replace magic number in DECODING_TABLE

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/fileupload/trunk@1458051 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml
index ddacad7..4dab0f4 100644
--- a/src/checkstyle/checkstyle-suppressions.xml
+++ b/src/checkstyle/checkstyle-suppressions.xml
@@ -19,6 +19,6 @@
    limitations under the License.
 -->
 <suppressions>
-  <suppress checks="MagicNumber" files="(Base64|QuotedPrintable)Decoder.java" lines="0-9999"/>
+  <suppress checks="MagicNumber" files="(Base64x|QuotedP)Decoder.java" lines="0-9999"/>
   <suppress checks="[a-zA-Z0-9]*" files=".+\.properties" />
 </suppressions>
diff --git a/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java b/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java
index 8bdc04f..5f1533d 100644
--- a/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java
+++ b/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java
@@ -1,76 +1,76 @@
-/*

- * Licensed to the Apache Software Foundation (ASF) under one or more

- * contributor license agreements.  See the NOTICE file distributed with

- * this work for additional information regarding copyright ownership.

- * The ASF licenses this file to You under the Apache License, Version 2.0

- * (the "License"); you may not use this file except in compliance with

- * the License.  You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-package org.apache.commons.fileupload;

-

-import java.util.Iterator;

-

-/**

- * <p> This class provides support for accessing the headers for a file or form

- * item that was received within a <code>multipart/form-data</code> POST

- * request.</p>

- *

- * @since 1.2.1

- *

- * @version $Id$

- */

-public interface FileItemHeaders {

-

-    /**

-     * Returns the value of the specified part header as a <code>String</code>.

-     *

-     * If the part did not include a header of the specified name, this method

-     * return <code>null</code>.  If there are multiple headers with the same

-     * name, this method returns the first header in the item.  The header

-     * name is case insensitive.

-     *

-     * @param name a <code>String</code> specifying the header name

-     * @return a <code>String</code> containing the value of the requested

-     *         header, or <code>null</code> if the item does not have a header

-     *         of that name

-     */

-    String getHeader(String name);

-

-    /**

-     * <p>

-     * Returns all the values of the specified item header as an

-     * <code>Iterator</code> of <code>String</code> objects.

-     * </p>

-     * <p>

-     * If the item did not include any headers of the specified name, this

-     * method returns an empty <code>Iterator</code>. The header name is

-     * case insensitive.

-     * </p>

-     *

-     * @param name a <code>String</code> specifying the header name

-     * @return an <code>Iterator</code> containing the values of the

-     *         requested header. If the item does not have any headers of

-     *         that name, return an empty <code>Iterator</code>

-     */

-    Iterator<String> getHeaders(String name);

-

-    /**

-     * <p>

-     * Returns an <code>Iterator</code> of all the header names.

-     * </p>

-     *

-     * @return an <code>Iterator</code> containing all of the names of

-     *         headers provided with this file item. If the item does not have

-     *         any headers return an empty <code>Iterator</code>

-     */

-    Iterator<String> getHeaderNames();

-

-}

+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload;
+
+import java.util.Iterator;
+
+/**
+ * <p> This class provides support for accessing the headers for a file or form
+ * item that was received within a <code>multipart/form-data</code> POST
+ * request.</p>
+ *
+ * @since 1.2.1
+ *
+ * @version $Id$
+ */
+public interface FileItemHeaders {
+
+    /**
+     * Returns the value of the specified part header as a <code>String</code>.
+     *
+     * If the part did not include a header of the specified name, this method
+     * return <code>null</code>.  If there are multiple headers with the same
+     * name, this method returns the first header in the item.  The header
+     * name is case insensitive.
+     *
+     * @param name a <code>String</code> specifying the header name
+     * @return a <code>String</code> containing the value of the requested
+     *         header, or <code>null</code> if the item does not have a header
+     *         of that name
+     */
+    String getHeader(String name);
+
+    /**
+     * <p>
+     * Returns all the values of the specified item header as an
+     * <code>Iterator</code> of <code>String</code> objects.
+     * </p>
+     * <p>
+     * If the item did not include any headers of the specified name, this
+     * method returns an empty <code>Iterator</code>. The header name is
+     * case insensitive.
+     * </p>
+     *
+     * @param name a <code>String</code> specifying the header name
+     * @return an <code>Iterator</code> containing the values of the
+     *         requested header. If the item does not have any headers of
+     *         that name, return an empty <code>Iterator</code>
+     */
+    Iterator<String> getHeaders(String name);
+
+    /**
+     * <p>
+     * Returns an <code>Iterator</code> of all the header names.
+     * </p>
+     *
+     * @return an <code>Iterator</code> containing all of the names of
+     *         headers provided with this file item. If the item does not have
+     *         any headers return an empty <code>Iterator</code>
+     */
+    Iterator<String> getHeaderNames();
+
+}
diff --git a/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java b/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java
index af5d482..4b372f6 100644
--- a/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java
+++ b/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java
@@ -1,50 +1,50 @@
-/*

- * Licensed to the Apache Software Foundation (ASF) under one or more

- * contributor license agreements.  See the NOTICE file distributed with

- * this work for additional information regarding copyright ownership.

- * The ASF licenses this file to You under the Apache License, Version 2.0

- * (the "License"); you may not use this file except in compliance with

- * the License.  You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-package org.apache.commons.fileupload;

-

-/**

- * Interface that will indicate that {@link FileItem} or {@link FileItemStream}

- * implementations will accept the headers read for the item.

- *

- * @since 1.2.1

- *

- * @see FileItem

- * @see FileItemStream

- *

- * @version $Id$

- */

-public interface FileItemHeadersSupport {

-

-    /**

-     * Returns the collection of headers defined locally within this item.

-     *

-     * @return the {@link FileItemHeaders} present for this item.

-     */

-    FileItemHeaders getHeaders();

-

-    /**

-     * Sets the headers read from within an item.  Implementations of

-     * {@link FileItem} or {@link FileItemStream} should implement this

-     * interface to be able to get the raw headers found within the item

-     * header block.

-     *

-     * @param headers the instance that holds onto the headers

-     *         for this instance.

-     */

-    void setHeaders(FileItemHeaders headers);

-

-}

+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload;
+
+/**
+ * Interface that will indicate that {@link FileItem} or {@link FileItemStream}
+ * implementations will accept the headers read for the item.
+ *
+ * @since 1.2.1
+ *
+ * @see FileItem
+ * @see FileItemStream
+ *
+ * @version $Id$
+ */
+public interface FileItemHeadersSupport {
+
+    /**
+     * Returns the collection of headers defined locally within this item.
+     *
+     * @return the {@link FileItemHeaders} present for this item.
+     */
+    FileItemHeaders getHeaders();
+
+    /**
+     * Sets the headers read from within an item.  Implementations of
+     * {@link FileItem} or {@link FileItemStream} should implement this
+     * interface to be able to get the raw headers found within the item
+     * header block.
+     *
+     * @param headers the instance that holds onto the headers
+     *         for this instance.
+     */
+    void setHeaders(FileItemHeaders headers);
+
+}
diff --git a/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java b/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
index f5f64ea..da3c087 100644
--- a/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
+++ b/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
@@ -39,9 +39,11 @@
     private static final int UPPER_NIBBLE_SHIFT = Byte.SIZE / 2;
 
     /**
-     * Set up the decoding table.
+     * Set up the decoding table; this is indexed by a byte converted to an int,
+     * so must be at least as large as the number of different byte values,
+     * positive and negative and zero.
      */
-    private static final byte[] DECODING_TABLE = new byte[128];
+    private static final byte[] DECODING_TABLE = new byte[Byte.MAX_VALUE - Byte.MIN_VALUE + 1];
 
     static {
         // initialize the decoding table
diff --git a/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java b/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
index 8bd54c5..2042488 100644
--- a/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
+++ b/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
@@ -1,90 +1,90 @@
-/*

- * Licensed to the Apache Software Foundation (ASF) under one or more

- * contributor license agreements.  See the NOTICE file distributed with

- * this work for additional information regarding copyright ownership.

- * The ASF licenses this file to You under the Apache License, Version 2.0

- * (the "License"); you may not use this file except in compliance with

- * the License.  You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-package org.apache.commons.fileupload;

-

-import static org.junit.Assert.assertEquals;

-import static org.junit.Assert.assertFalse;

-import static org.junit.Assert.assertNull;

-import static org.junit.Assert.assertTrue;

-

-import java.util.Iterator;

-

-import org.apache.commons.fileupload.util.FileItemHeadersImpl;

-import org.junit.Test;

-

-/**

- * Unit tests {@link FileItemHeaders} and

- * {@link FileItemHeadersImpl}.

- *

- * @version $Id$

- */

-public class FileItemHeadersTest {

-

-    /**

-     * @throws Exception

-     */

-    @Test

-    public void testFileItemHeaders() throws Exception {

-        FileItemHeadersImpl aMutableFileItemHeaders = new FileItemHeadersImpl();

-        aMutableFileItemHeaders.addHeader("Content-Disposition", "form-data; name=\"FileItem\"; filename=\"file1.txt\"");

-        aMutableFileItemHeaders.addHeader("Content-Type", "text/plain");

-

-        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue1");

-        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue2");

-        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue3");

-        aMutableFileItemHeaders.addHeader("testheader", "headerValue4");

-

-        Iterator<String> headerNameEnumeration = aMutableFileItemHeaders.getHeaderNames();

-        assertEquals("content-disposition", headerNameEnumeration.next());

-        assertEquals("content-type", headerNameEnumeration.next());

-        assertEquals("testheader", headerNameEnumeration.next());

-        assertFalse(headerNameEnumeration.hasNext());

-

-        assertEquals(aMutableFileItemHeaders.getHeader("Content-Disposition"), "form-data; name=\"FileItem\"; filename=\"file1.txt\"");

-        assertEquals(aMutableFileItemHeaders.getHeader("Content-Type"), "text/plain");

-        assertEquals(aMutableFileItemHeaders.getHeader("content-type"), "text/plain");

-        assertEquals(aMutableFileItemHeaders.getHeader("TestHeader"), "headerValue1");

-        assertNull(aMutableFileItemHeaders.getHeader("DummyHeader"));

-

-        Iterator<String> headerValueEnumeration;

-

-        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("Content-Type");

-        assertTrue(headerValueEnumeration.hasNext());

-        assertEquals(headerValueEnumeration.next(), "text/plain");

-        assertFalse(headerValueEnumeration.hasNext());

-

-        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("content-type");

-        assertTrue(headerValueEnumeration.hasNext());

-        assertEquals(headerValueEnumeration.next(), "text/plain");

-        assertFalse(headerValueEnumeration.hasNext());

-

-        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("TestHeader");

-        assertTrue(headerValueEnumeration.hasNext());

-        assertEquals(headerValueEnumeration.next(), "headerValue1");

-        assertTrue(headerValueEnumeration.hasNext());

-        assertEquals(headerValueEnumeration.next(), "headerValue2");

-        assertTrue(headerValueEnumeration.hasNext());

-        assertEquals(headerValueEnumeration.next(), "headerValue3");

-        assertTrue(headerValueEnumeration.hasNext());

-        assertEquals(headerValueEnumeration.next(), "headerValue4");

-        assertFalse(headerValueEnumeration.hasNext());

-

-        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("DummyHeader");

-        assertFalse(headerValueEnumeration.hasNext());

-    }

-

-}

+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Iterator;
+
+import org.apache.commons.fileupload.util.FileItemHeadersImpl;
+import org.junit.Test;
+
+/**
+ * Unit tests {@link FileItemHeaders} and
+ * {@link FileItemHeadersImpl}.
+ *
+ * @version $Id$
+ */
+public class FileItemHeadersTest {
+
+    /**
+     * @throws Exception
+     */
+    @Test
+    public void testFileItemHeaders() throws Exception {
+        FileItemHeadersImpl aMutableFileItemHeaders = new FileItemHeadersImpl();
+        aMutableFileItemHeaders.addHeader("Content-Disposition", "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
+        aMutableFileItemHeaders.addHeader("Content-Type", "text/plain");
+
+        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue1");
+        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue2");
+        aMutableFileItemHeaders.addHeader("TestHeader", "headerValue3");
+        aMutableFileItemHeaders.addHeader("testheader", "headerValue4");
+
+        Iterator<String> headerNameEnumeration = aMutableFileItemHeaders.getHeaderNames();
+        assertEquals("content-disposition", headerNameEnumeration.next());
+        assertEquals("content-type", headerNameEnumeration.next());
+        assertEquals("testheader", headerNameEnumeration.next());
+        assertFalse(headerNameEnumeration.hasNext());
+
+        assertEquals(aMutableFileItemHeaders.getHeader("Content-Disposition"), "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
+        assertEquals(aMutableFileItemHeaders.getHeader("Content-Type"), "text/plain");
+        assertEquals(aMutableFileItemHeaders.getHeader("content-type"), "text/plain");
+        assertEquals(aMutableFileItemHeaders.getHeader("TestHeader"), "headerValue1");
+        assertNull(aMutableFileItemHeaders.getHeader("DummyHeader"));
+
+        Iterator<String> headerValueEnumeration;
+
+        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("Content-Type");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "text/plain");
+        assertFalse(headerValueEnumeration.hasNext());
+
+        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("content-type");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "text/plain");
+        assertFalse(headerValueEnumeration.hasNext());
+
+        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("TestHeader");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "headerValue1");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "headerValue2");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "headerValue3");
+        assertTrue(headerValueEnumeration.hasNext());
+        assertEquals(headerValueEnumeration.next(), "headerValue4");
+        assertFalse(headerValueEnumeration.hasNext());
+
+        headerValueEnumeration = aMutableFileItemHeaders.getHeaders("DummyHeader");
+        assertFalse(headerValueEnumeration.hasNext());
+    }
+
+}