From 161a3b177943af4949c3bfa1aba8dab5b0106ae6 Mon Sep 17 00:00:00 2001
From: Mark Thomas
- We recommend you use a mirror to download our release
- builds, but you must verify the integrity of
- the downloaded files using signatures downloaded from our main
- distribution directories. Recent releases (48 hours) may not yet
- be available from the mirrors.
-
- You are currently using [preferred]. If you
- encounter a problem with this mirror, please select another
- mirror. If all mirrors are failing, there are backup
- mirrors (at the end of the mirrors list) that should be
- available.
-
- The KEYS
- link links to the code signing keys used to sign the product.
- The
+ We recommend you use a mirror to download our release
+ builds, but you must verify the integrity of
+ the downloaded files using signatures downloaded from our main
+ distribution directories. Recent releases (48 hours) may not yet
+ be available from all the mirrors.
+
+ You are currently using [preferred]. If you
+ encounter a problem with this mirror, please select another
+ mirror. If all mirrors are failing, there are backup
+ mirrors (at the end of the mirrors list) that should be
+ available.
+
+ It is essential that you
+ verify the integrity
+ of downloaded files, preferably using the
+ The KEYS
+ file contains the public PGP keys used by Apache Commons developers
+ to sign releases.
+ null
, the request
@@ -337,7 +362,11 @@ public List
- [if-any logo][end]
-
PGP
link downloads the OpenPGP compatible signature from our main site.
- The SHA256
link downloads the checksum from the main site.
-
+ [if-any logo][end]
+
PGP
signature (*.asc
files);
+ failing that using the SHA512
hash (*.sha512
checksum files).
+
-
commons-fileupload-1.4-bin.tar.gz
- sha256
- pgp
+ commons-fileupload-1.5-bin.tar.gz
+ sha512
+ pgp
-
commons-fileupload-1.4-bin.zip
- sha256
- pgp
+ commons-fileupload-1.5-bin.zip
+ sha512
+ pgp
-
commons-fileupload-1.4-src.tar.gz
- sha256
- pgp
+ commons-fileupload-1.5-src.tar.gz
+ sha512
+ pgp
-
commons-fileupload-1.4-src.zip
- sha256
- pgp
+ commons-fileupload-1.5-src.zip
+ sha512
+ pgp
- Commons FileUpload uses ASF JIRA for tracking issues. - See the Commons FileUpload JIRA project page. + Apache Commons FileUpload uses ASF JIRA for tracking issues. + See the Apache Commons FileUpload JIRA project page.
- To use JIRA you may need to create an account + To use JIRA you may need to create an account (if you have previously created/updated Commons issues using Bugzilla an account will have been automatically - created and you can use the Forgot Password + created and you can use the Forgot Password page to get a new password).
If you would like to report a bug, or raise an enhancement request with - Commons FileUpload please do the following: + Apache Commons FileUpload please do the following:
For more information on subversion and creating patches see the - Apache Contributors Guide. + Apache Contributors Guide.
You may also find these links useful:
- Commons FileUpload shares mailing lists with all the other - Commons Components. + Apache Commons FileUpload shares mailing lists with all the other + Commons Components. To make it easier for people to only read messages related to components they are interested in, the convention in Commons is to prefix the subject line of messages with the component's name, for example: @@ -58,24 +58,27 @@ limitations under the License.
- Questions related to the usage of Commons FileUpload should be posted to the
- User List.
+ Questions related to the usage of Apache Commons FileUpload should be posted to the
+ User List.
- The Developer List
- is for questions and discussion related to the development of Commons FileUpload.
+ The Developer List
+ is for questions and discussion related to the development of Apache Commons FileUpload.
Please do not cross-post; developers are also subscribed to the user list.
+
+ You must be subscribed to post to the mailing lists. Follow the Subscribe links below
+ to subscribe.
Note: please don't send patches or attachments to any of the mailing lists. - Patches are best handled via the Issue Tracking system. - Otherwise, please upload the file to a public server and include the URL in the mail. + Patches are best handled via the Issue Tracking system. + Otherwise, please upload the file to a public server and include the URL in the mail.
- Please prefix the subject line of any messages for Commons FileUpload
+ Please prefix the subject line of any messages for Apache Commons FileUpload
with [fileupload] - thanks!
@@ -96,16 +99,18 @@ limitations under the License.
Commons User List
- Questions on using Commons FileUpload.
+ Questions on using Apache Commons FileUpload.
Subscribe
Unsubscribe
Post
- mail-archives.apache.org
- markmail.org
- www.mail-archive.com
- news.gmane.org
+ mail-archives.apache.org
+
+ lists.apache.org
+ markmail.org
@@ -114,16 +119,18 @@ limitations under the License.
+ www.mail-archive.com
+ news.gmane.org
Commons Developer List
- Discussion of development of Commons FileUpload.
+ Discussion of development of Apache Commons FileUpload.
Subscribe
Unsubscribe
Post
- mail-archives.apache.org
- markmail.org
- www.mail-archive.com
- news.gmane.org
+ mail-archives.apache.org
+
+ lists.apache.org
+ markmail.org
@@ -138,9 +145,11 @@ limitations under the License.
+ www.mail-archive.com
+ news.gmane.org
Subscribe
Unsubscribe
read only
- mail-archives.apache.org
- markmail.org
- www.mail-archive.com
+ mail-archives.apache.org
+
+ lists.apache.org
+ markmail.org
@@ -149,15 +158,17 @@ limitations under the License.
+ www.mail-archive.com
Commons Commits List
- Only for e-mails automatically generated by the source control sytem.
+ Only for e-mails automatically generated by the source control sytem.
Subscribe
Unsubscribe
read only
- mail-archives.apache.org
- markmail.org
- www.mail-archive.com
+ mail-archives.apache.org
+
+ lists.apache.org
+ markmail.org
@@ -185,14 +196,16 @@ limitations under the License.
General announcements of Apache project releases.
+ www.mail-archive.com
- Subscribe
- Unsubscribe
+ Subscribe
+ Unsubscribe
read only
- mail-archives.apache.org
- markmail.org
- old.nabble.com
- www.mail-archive.com
- news.gmane.org
+ mail-archives.apache.org
+
+ lists.apache.org
+ markmail.org
From 249434655e70430e5937b20c515eb95b37c47ad5 Mon Sep 17 00:00:00 2001
From: Mark Thomas
+ old.nabble.com
+ www.mail-archive.com
+ news.gmane.org
Important: Denial of Service CVE-2023-24998
+ +Apache Commons FileUpload before 1.5 does not limit the number of + request parts to be processed resulting in the possibility of an + attacker triggering a DoS with a malicious upload or series of + uploads.
+ +This was fixed in commit + e20c0499.
+ +Affects: 1.0? - 1.4
+Regarding potential security problems with the class called DiskFileItem, @@ -91,7 +107,7 @@ boundary is close to the size of the buffer in MultipartStream. This is also fixed for Apache Tomcat.
-This was fixed in revisions +
This was fixed in revision 1743480.
Affects: 1.0? - 1.3.1
@@ -107,7 +123,7 @@ loop and CPU consumption) via a crafted Content-Type header that bypasses a loop's intended exit conditions. -This was fixed in revisions +
This was fixed in revision 1565143.
Affects: 1.0? - 1.3
@@ -121,7 +137,7 @@Update the Javadoc and documentation to make it clear that setting a repository is required for a secure configuration if there are local, untrusted users.
-This was fixed in revisions +
This was fixed in revision 1453273.
Affects: 1.0 - 1.2.2
From c4f32a13298f6b9561c136b61b23c9e2c6d82368 Mon Sep 17 00:00:00 2001 From: Mark ThomasImportant: Denial of Service CVE-2023-24998
-Apache Commons FileUpload before 1.5 does not limit the number of - request parts to be processed resulting in the possibility of an - attacker triggering a DoS with a malicious upload or series of - uploads.
+Apache Commons FileUpload before 1.5 does not provide an option to + limit the number of request parts to be processed resulting in the + possibility of an attacker triggering a DoS with a malicious upload or + series of uploads. Note that, like all of the file upload limits, the + new configuration option (FileUploadBase#setFileCountMax) is not + enabled by default and must be explicitly configured.
This was fixed in commit
Date: Fri, 15 Sep 2023 18:27:53 +0100
Subject: [PATCH 037/224] High level API for processing file uploads. This class handles multiple files per single HTML widget, sent using
- * This class represents a file or form item that was received within a
- * After retrieving an instance of this class from a {@link
* org.apache.commons.fileupload.FileUpload FileUpload} instance (see
@@ -36,11 +36,11 @@
* it into memory, which may come handy with large files.
*
* While this interface does not extend
- * This class provides support for accessing the headers for a file or form
- * item that was received within a
* Returns all the values of the specified item header as an
- *
* If the item did not include any headers of the specified name, this
- * method returns an empty
- * Returns an This interface provides access to a file or form item that was
- * received within a Instances of this class are created by accessing the
* iterator, returned by
@@ -64,10 +64,10 @@ class ItemSkippedException extends IOException {
InputStream openStream() throws IOException;
/**
- * Returns the content type passed by the browser or High level API for processing file uploads. This class handles multiple files per single HTML widget, sent using
- * High level API for processing file uploads. This class handles multiple files per single HTML widget, sent using
- * NOTE:This method will be moved to the
- * Parses the Parses the {@code header-part} and returns as key/value
* pairs.
*
* If there are multiple headers of the same names, the name
* will map to a comma-separated list containing the values.
*
- * @param headerPart The Parses the Parses the {@code header-part} and returns as key/value
* pairs.
*
* If there are multiple headers of the same names, the name
* will map to a comma-separated list containing the values.
*
- * @param headerPart The Constructs a Constructs a {@code MultipartStream} with a custom size buffer
* and no progress notifier.
*
* Note that the buffer must be at least big enough to contain the
@@ -288,9 +288,9 @@ public MultipartStream() {
* least one byte of data. Too small a buffer size setting will degrade
* performance.
*
- * @param input The Constructs a Constructs a {@code MultipartStream} with a custom size buffer.
*
* Note that the buffer must be at least big enough to contain the
* boundary string, plus 4 characters for CR/LF and double dash, plus at
* least one byte of data. Too small a buffer size setting will degrade
* performance.
*
- * @param input The Constructs a Constructs a {@code MultipartStream} with a default size buffer.
*
- * @param input The Constructs a Constructs a {@code MultipartStream} with a default size buffer.
*
- * @param input The This method allows single pass processing of nested multipart
* streams.
*
- * The boundary token of the nested stream is The boundary token of the nested stream is {@code required}
* to be of the same length as the boundary token in parent stream.
*
* Restoring the parent stream boundary token after processing of a
@@ -499,7 +499,7 @@ public boolean readBoundary()
* @param boundary The boundary to be used for parsing of the nested
* stream.
*
- * @throws IllegalBoundaryException if the Reads the Reads the {@code header-part} of the current
+ * {@code encapsulation}.
*
* Headers are returned verbatim to the input stream, including the
- * trailing TODO allow limiting maximum header size to
* protect against abuse.
*
- * @return The Reads Reads {@code body-data} from the current
+ * {@code encapsulation} and writes its contents into the
+ * output {@code Stream}.
*
* Arbitrary large amounts of data can be processed by this
* method using a constant size buffer. (see {@link
* #MultipartStream(InputStream,byte[],int,
* MultipartStream.ProgressNotifier) constructor}).
*
- * @param output The Reads Reads {@code body-data} from the current
+ * {@code encapsulation} and discards it.
*
* Use this method to skip encapsulations you don't need or don't
* understand.
@@ -647,9 +647,9 @@ public int discardBodyData() throws MalformedStreamException, IOException {
}
/**
- * Finds the beginning of the first
- *
* Note: Subclasses that override this method must ensure that they return the
diff --git a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java
index edcaec1cdf..04861a47f7 100644
--- a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java
+++ b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java
@@ -36,7 +36,7 @@
*
* NOTE: Files are created in the system default temp directory with
@@ -47,7 +47,7 @@
* implementation in an environment with local, untrusted users,
* {@link #setRepository(File)} MUST be used to configure a repository location
* that is not publicly writable. In a Servlet container the location identified
- * by the ServletContext attribute
* In the example above, the first file is loaded into memory as a
- * High level API for processing file uploads. This class handles multiple files per single HTML widget, sent using
- * High level API for processing file uploads. This class handles multiple files per single HTML widget, sent using
- *
* This method
- * simply performs
- * This method simply performs Secondly this happens when attempting to rely on a shared copy of
the Commons FileUpload jar file provided by your web container. The
diff --git a/src/site/xdoc/streaming.xml b/src/site/xdoc/streaming.xml
index a765975303..6802d641e2 100644
--- a/src/site/xdoc/streaming.xml
+++ b/src/site/xdoc/streaming.xml
@@ -41,9 +41,9 @@
- Again, the
@@ -67,15 +67,15 @@
Each file item has a number of properties that might be of interest for
your application. For example, every item has a name and a content type,
- and can provide an
- FileUpload creates new file items using a X
-> {@code X}
---
.../commons/fileupload/DefaultFileItem.java | 10 +-
.../fileupload/DefaultFileItemFactory.java | 14 +--
.../commons/fileupload/DiskFileUpload.java | 38 +++---
.../apache/commons/fileupload/FileItem.java | 30 ++---
.../commons/fileupload/FileItemFactory.java | 4 +-
.../commons/fileupload/FileItemHeaders.java | 28 ++---
.../commons/fileupload/FileItemStream.java | 12 +-
.../apache/commons/fileupload/FileUpload.java | 6 +-
.../commons/fileupload/FileUploadBase.java | 100 ++++++++--------
.../fileupload/FileUploadException.java | 10 +-
.../commons/fileupload/MultipartStream.java | 108 +++++++++---------
.../commons/fileupload/ParameterParser.java | 2 +-
.../commons/fileupload/disk/DiskFileItem.java | 46 ++++----
.../fileupload/disk/DiskFileItemFactory.java | 8 +-
.../commons/fileupload/package-info.java | 2 +-
.../fileupload/portlet/PortletFileUpload.java | 22 ++--
.../fileupload/portlet/package-info.java | 2 +-
.../fileupload/servlet/ServletFileUpload.java | 22 ++--
.../fileupload/servlet/package-info.java | 2 +-
.../fileupload/util/FileItemHeadersImpl.java | 4 +-
.../fileupload/util/LimitedInputStream.java | 32 +++---
src/site/fml/faq.fml | 2 +-
src/site/xdoc/streaming.xml | 4 +-
src/site/xdoc/using.xml | 40 +++----
.../fileupload/DefaultFileItemTest.java | 4 +-
25 files changed, 276 insertions(+), 276 deletions(-)
diff --git a/src/main/java/org/apache/commons/fileupload/DefaultFileItem.java b/src/main/java/org/apache/commons/fileupload/DefaultFileItem.java
index a7eb617e95..39d3a84ccb 100644
--- a/src/main/java/org/apache/commons/fileupload/DefaultFileItem.java
+++ b/src/main/java/org/apache/commons/fileupload/DefaultFileItem.java
@@ -32,7 +32,7 @@
* {@link #getInputStream()} and process the file without attempting to load
* it into memory, which may come handy with large files.
*
- * @deprecated 1.1 Use DiskFileItem
instead.
+ * @deprecated 1.1 Use {@code DiskFileItem} instead.
*/
@Deprecated
public class DefaultFileItem
@@ -41,15 +41,15 @@ public class DefaultFileItem
// ----------------------------------------------------------- Constructors
/**
- * Constructs a new DefaultFileItem
instance.
+ * Constructs a new {@code DefaultFileItem} instance.
*
* @param fieldName The name of the form field.
* @param contentType The content type passed by the browser or
- * null
if not specified.
+ * {@code null} if not specified.
* @param isFormField Whether or not this item is a plain form field, as
* opposed to a file upload.
* @param fileName The original filename in the user's filesystem, or
- * null
if not specified.
+ * {@code null} if not specified.
* @param sizeThreshold The threshold, in bytes, below which items will be
* retained in memory and above which they will be
* stored as a file.
@@ -57,7 +57,7 @@ public class DefaultFileItem
* which files will be created, should the item size
* exceed the threshold.
*
- * @deprecated 1.1 Use DiskFileItem
instead.
+ * @deprecated 1.1 Use {@code DiskFileItem} instead.
*/
@Deprecated
public DefaultFileItem(String fieldName, String contentType,
diff --git a/src/main/java/org/apache/commons/fileupload/DefaultFileItemFactory.java b/src/main/java/org/apache/commons/fileupload/DefaultFileItemFactory.java
index 46bc7a37e1..d1273fe247 100644
--- a/src/main/java/org/apache/commons/fileupload/DefaultFileItemFactory.java
+++ b/src/main/java/org/apache/commons/fileupload/DefaultFileItemFactory.java
@@ -33,10 +33,10 @@
*
*
*
- * @deprecated 1.1 Use System.getProperty("java.io.tmpdir")
.DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
*/
@Deprecated
public class DefaultFileItemFactory extends DiskFileItemFactory {
@@ -47,7 +47,7 @@ public class DefaultFileItemFactory extends DiskFileItemFactory {
* Constructs an unconfigured instance of this class. The resulting factory
* may be configured by calling the appropriate setter methods.
*
- * @deprecated 1.1 Use DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
*/
@Deprecated
public DefaultFileItemFactory() {
@@ -64,7 +64,7 @@ public DefaultFileItemFactory() {
* which files will be created, should the item size
* exceed the threshold.
*
- * @deprecated 1.1 Use DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
*/
@Deprecated
public DefaultFileItemFactory(int sizeThreshold, File repository) {
@@ -80,14 +80,14 @@ public DefaultFileItemFactory(int sizeThreshold, File repository) {
*
* @param fieldName The name of the form field.
* @param contentType The content type of the form field.
- * @param isFormField true
if this is a plain form field;
- * false
otherwise.
+ * @param isFormField {@code true} if this is a plain form field;
+ * {@code false} otherwise.
* @param fileName The name of the uploaded file, if any, as supplied
* by the browser or other client.
*
* @return The newly created file item.
*
- * @deprecated 1.1 Use DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
*/
@Override
@Deprecated
diff --git a/src/main/java/org/apache/commons/fileupload/DiskFileUpload.java b/src/main/java/org/apache/commons/fileupload/DiskFileUpload.java
index 3fad4f10fd..734e5e8532 100644
--- a/src/main/java/org/apache/commons/fileupload/DiskFileUpload.java
+++ b/src/main/java/org/apache/commons/fileupload/DiskFileUpload.java
@@ -24,7 +24,7 @@
* multipart/mixed
encoding type, as specified by
+ * {@code multipart/mixed} encoding type, as specified by
* RFC 1867. Use {@link
* #parseRequest(HttpServletRequest)} to acquire a list of {@link
* org.apache.commons.fileupload.FileItem}s associated with a given HTML
@@ -34,8 +34,8 @@
* depending on their size, and will be available as {@link
* org.apache.commons.fileupload.FileItem}s.ServletFileUpload
together with
- * DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code ServletFileUpload} together with
+ * {@code DiskFileItemFactory} instead.
*/
@Deprecated
public class DiskFileUpload
@@ -52,11 +52,11 @@ public class DiskFileUpload
/**
* Constructs an instance of this class which uses the default factory to
- * create FileItem
instances.
+ * create {@code FileItem} instances.
*
* @see #DiskFileUpload(DefaultFileItemFactory fileItemFactory)
*
- * @deprecated 1.1 Use FileUpload
instead.
+ * @deprecated 1.1 Use {@code FileUpload} instead.
*/
@Deprecated
public DiskFileUpload() {
@@ -66,12 +66,12 @@ public DiskFileUpload() {
/**
* Constructs an instance of this class which uses the supplied factory to
- * create FileItem
instances.
+ * create {@code FileItem} instances.
*
* @see #DiskFileUpload()
* @param fileItemFactory The file item factory to use.
*
- * @deprecated 1.1 Use FileUpload
instead.
+ * @deprecated 1.1 Use {@code FileUpload} instead.
*/
@Deprecated
public DiskFileUpload(DefaultFileItemFactory fileItemFactory) {
@@ -86,7 +86,7 @@ public DiskFileUpload(DefaultFileItemFactory fileItemFactory) {
*
* @return The factory class for new file items.
*
- * @deprecated 1.1 Use FileUpload
instead.
+ * @deprecated 1.1 Use {@code FileUpload} instead.
*/
@Override
@Deprecated
@@ -96,12 +96,12 @@ public FileItemFactory getFileItemFactory() {
/**
* Sets the factory class to use when creating file items. The factory must
- * be an instance of DefaultFileItemFactory
or a subclass
- * thereof, or else a ClassCastException
will be thrown.
+ * be an instance of {@code DefaultFileItemFactory} or a subclass
+ * thereof, or else a {@code ClassCastException} will be thrown.
*
* @param factory The factory class for new file items.
*
- * @deprecated 1.1 Use FileUpload
instead.
+ * @deprecated 1.1 Use {@code FileUpload} instead.
*/
@Override
@Deprecated
@@ -117,7 +117,7 @@ public void setFileItemFactory(FileItemFactory factory) {
*
* @see #setSizeThreshold(int)
*
- * @deprecated 1.1 Use DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
*/
@Deprecated
public int getSizeThreshold() {
@@ -131,7 +131,7 @@ public int getSizeThreshold() {
*
* @see #getSizeThreshold()
*
- * @deprecated 1.1 Use DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
*/
@Deprecated
public void setSizeThreshold(int sizeThreshold) {
@@ -146,7 +146,7 @@ public void setSizeThreshold(int sizeThreshold) {
*
* @see #setRepositoryPath(String)
*
- * @deprecated 1.1 Use DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
*/
@Deprecated
public String getRepositoryPath() {
@@ -161,7 +161,7 @@ public String getRepositoryPath() {
*
* @see #getRepositoryPath()
*
- * @deprecated 1.1 Use DiskFileItemFactory
instead.
+ * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
*/
@Deprecated
public void setRepositoryPath(String repositoryPath) {
@@ -172,21 +172,21 @@ public void setRepositoryPath(String repositoryPath) {
/**
* Processes an RFC 1867
- * compliant multipart/form-data
stream. If files are stored
- * on disk, the path is given by getRepository()
.
+ * compliant {@code multipart/form-data} stream. If files are stored
+ * on disk, the path is given by {@code getRepository()}.
*
* @param req The servlet request to be parsed. Must be non-null.
* @param sizeThreshold The max size in bytes to be stored in memory.
* @param sizeMax The maximum allowed upload size, in bytes.
* @param path The location where the files should be stored.
*
- * @return A list of FileItem
instances parsed from the
+ * @return A list of {@code FileItem} instances parsed from the
* request, in the order that they were transmitted.
*
* @throws FileUploadException if there are problems reading/parsing
* the request or storing files.
*
- * @deprecated 1.1 Use ServletFileUpload
instead.
+ * @deprecated 1.1 Use {@code ServletFileUpload} instead.
*/
@Deprecated
public Listmultipart/form-data
POST request.
+ * {@code multipart/form-data} POST request.
*
* javax.activation.DataSource
per se (to avoid a seldom used
+ * {@code javax.activation.DataSource} per se (to avoid a seldom used
* dependency), several of the defined methods are specifically defined with
* the same signatures as methods in that interface. This allows an
* implementation of this interface to also implement
- * javax.activation.DataSource
with minimal additional work.
+ * {@code javax.activation.DataSource} with minimal additional work.
*
* @since 1.3 additionally implements FileItemHeadersSupport
*/
@@ -60,10 +60,10 @@ public interface FileItem extends FileItemHeadersSupport {
InputStream getInputStream() throws IOException;
/**
- * Returns the content type passed by the browser or null
if
+ * Returns the content type passed by the browser or {@code null} if
* not defined.
*
- * @return The content type passed by the browser or null
if
+ * @return The content type passed by the browser or {@code null} if
* not defined.
*/
String getContentType();
@@ -88,8 +88,8 @@ public interface FileItem extends FileItemHeadersSupport {
* Provides a hint as to whether or not the file contents will be read
* from memory.
*
- * @return true
if the file contents will be read from memory;
- * false
otherwise.
+ * @return {@code true} if the file contents will be read from memory;
+ * {@code false} otherwise.
*/
boolean isInMemory();
@@ -141,7 +141,7 @@ public interface FileItem extends FileItemHeadersSupport {
* example, file renaming, where possible, rather than copying all of the
* underlying data, thus gaining a significant performance benefit.
*
- * @param file The File
into which the uploaded item should
+ * @param file The {@code File} into which the uploaded item should
* be stored.
*
* @throws Exception if an error occurs.
@@ -151,7 +151,7 @@ public interface FileItem extends FileItemHeadersSupport {
/**
* Deletes the underlying storage for a file item, including deleting any
* associated temporary disk file. Although this storage will be deleted
- * automatically when the FileItem
instance is garbage
+ * automatically when the {@code FileItem} instance is garbage
* collected, this method can be used to ensure that this is done at an
* earlier time, thus preserving system resources.
*/
@@ -173,20 +173,20 @@ public interface FileItem extends FileItemHeadersSupport {
void setFieldName(String name);
/**
- * Determines whether or not a FileItem
instance represents
+ * Determines whether or not a {@code FileItem} instance represents
* a simple form field.
*
- * @return true
if the instance represents a simple form
- * field; false
if it represents an uploaded file.
+ * @return {@code true} if the instance represents a simple form
+ * field; {@code false} if it represents an uploaded file.
*/
boolean isFormField();
/**
- * Specifies whether or not a FileItem
instance represents
+ * Specifies whether or not a {@code FileItem} instance represents
* a simple form field.
*
- * @param state true
if the instance represents a simple form
- * field; false
if it represents an uploaded file.
+ * @param state {@code true} if the instance represents a simple form
+ * field; {@code false} if it represents an uploaded file.
*/
void setFormField(boolean state);
diff --git a/src/main/java/org/apache/commons/fileupload/FileItemFactory.java b/src/main/java/org/apache/commons/fileupload/FileItemFactory.java
index f450a0437b..a6aa209a8a 100644
--- a/src/main/java/org/apache/commons/fileupload/FileItemFactory.java
+++ b/src/main/java/org/apache/commons/fileupload/FileItemFactory.java
@@ -29,8 +29,8 @@ public interface FileItemFactory {
*
* @param fieldName The name of the form field.
* @param contentType The content type of the form field.
- * @param isFormField true
if this is a plain form field;
- * false
otherwise.
+ * @param isFormField {@code true} if this is a plain form field;
+ * {@code false} otherwise.
* @param fileName The name of the uploaded file, if any, as supplied
* by the browser or other client.
*
diff --git a/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java b/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java
index 3fbda6d8f6..2ed79dcaf2 100644
--- a/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java
+++ b/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java
@@ -20,7 +20,7 @@
/**
* multipart/form-data
POST
+ * item that was received within a {@code multipart/form-data} POST
* request.String
.
+ * Returns the value of the specified part header as a {@code String}.
*
* If the part did not include a header of the specified name, this method
- * return null
. If there are multiple headers with the same
+ * return {@code null}. 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 String
specifying the header name
- * @return a String
containing the value of the requested
- * header, or null
if the item does not have a header
+ * @param name a {@code String} specifying the header name
+ * @return a {@code String} containing the value of the requested
+ * header, or {@code null} if the item does not have a header
* of that name
*/
String getHeader(String name);
@@ -45,29 +45,29 @@ public interface FileItemHeaders {
/**
* Iterator
of String
objects.
+ * {@code Iterator} of {@code String} objects.
* Iterator
. The header name is
+ * method returns an empty {@code Iterator}. The header name is
* case insensitive.
* String
specifying the header name
- * @return an Iterator
containing the values of the
+ * @param name a {@code String} specifying the header name
+ * @return an {@code Iterator} containing the values of the
* requested header. If the item does not have any headers of
- * that name, return an empty Iterator
+ * that name, return an empty {@code Iterator}
*/
IteratorIterator
of all the header names.
+ * Returns an {@code Iterator} of all the header names.
* Iterator
containing all of the names of
+ * @return an {@code Iterator} containing all of the names of
* headers provided with this file item. If the item does not have
- * any headers return an empty Iterator
+ * any headers return an empty {@code Iterator}
*/
Iteratormultipart/form-data
POST request.
+ * received within a {@code multipart/form-data} POST request.
* The items contents are retrieved by calling {@link #openStream()}.null
if
+ * Returns the content type passed by the browser or {@code null} if
* not defined.
*
- * @return The content type passed by the browser or null
if
+ * @return The content type passed by the browser or {@code null} if
* not defined.
*/
String getContentType();
@@ -91,11 +91,11 @@ class ItemSkippedException extends IOException {
String getFieldName();
/**
- * Determines whether or not a FileItem
instance represents
+ * Determines whether or not a {@code FileItem} instance represents
* a simple form field.
*
- * @return true
if the instance represents a simple form
- * field; false
if it represents an uploaded file.
+ * @return {@code true} if the instance represents a simple form
+ * field; {@code false} if it represents an uploaded file.
*/
boolean isFormField();
diff --git a/src/main/java/org/apache/commons/fileupload/FileUpload.java b/src/main/java/org/apache/commons/fileupload/FileUpload.java
index 4a48a49b67..faf2e613c2 100644
--- a/src/main/java/org/apache/commons/fileupload/FileUpload.java
+++ b/src/main/java/org/apache/commons/fileupload/FileUpload.java
@@ -20,7 +20,7 @@
* multipart/mixed
encoding type, as specified by
+ * {@code multipart/mixed} encoding type, as specified by
* RFC 1867. Use {@link
* #parseRequest(RequestContext)} to acquire a list
* of {@link org.apache.commons.fileupload.FileItem FileItems} associated
@@ -46,7 +46,7 @@ public class FileUpload
* Constructs an uninitialised instance of this class.
*
* A factory must be
- * configured, using setFileItemFactory()
, before attempting
+ * configured, using {@code setFileItemFactory()}, before attempting
* to parse requests.
*
* @see #FileUpload(FileItemFactory)
@@ -57,7 +57,7 @@ public FileUpload() {
/**
* Constructs an instance of this class which uses the supplied factory to
- * create FileItem
instances.
+ * create {@code FileItem} instances.
*
* @see #FileUpload()
* @param fileItemFactory The factory to use for creating file items.
diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
index 1f64db21ef..d748f94aa3 100644
--- a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
+++ b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
@@ -44,7 +44,7 @@
* multipart/mixed
encoding type, as specified by
+ * {@code multipart/mixed} encoding type, as specified by
* RFC 1867. Use {@link
* #parseRequest(RequestContext)} to acquire a list of {@link
* org.apache.commons.fileupload.FileItem}s associated with a given HTML
@@ -63,14 +63,14 @@ public abstract class FileUploadBase {
* content.ServletFileUpload
class after the FileUpload 1.1 release.
+ * {@code ServletFileUpload} class after the FileUpload 1.1 release.
* Unfortunately, since this method is static, it is not possible to
* provide its replacement until this method is removed.true
if the request is multipart;
- * false
otherwise.
+ * @return {@code true} if the request is multipart;
+ * {@code false} otherwise.
*/
public static final boolean isMultipartContent(RequestContext ctx) {
String contentType = ctx.getContentType();
@@ -89,10 +89,10 @@ public static final boolean isMultipartContent(RequestContext ctx) {
*
* @param req The servlet request to be evaluated. Must be non-null.
*
- * @return true
if the request is multipart;
- * false
otherwise.
+ * @return {@code true} if the request is multipart;
+ * {@code false} otherwise.
*
- * @deprecated 1.1 Use the method on ServletFileUpload
instead.
+ * @deprecated 1.1 Use the method on {@code ServletFileUpload} instead.
*/
@Deprecated
public static boolean isMultipartContent(HttpServletRequest req) {
@@ -268,8 +268,8 @@ public void setFileCountMax(final long fileCountMax) {
/**
* Retrieves the character encoding used when reading the headers of an
- * individual part. When not specified, or null
, the request
- * encoding is used. If that is also not specified, or null
,
+ * individual part. When not specified, or {@code null}, the request
+ * encoding is used. If that is also not specified, or {@code null},
* the platform default encoding is used.
*
* @return The encoding used to read part headers.
@@ -280,8 +280,8 @@ public String getHeaderEncoding() {
/**
* Specifies the character encoding to be used when reading the headers of
- * individual part. When not specified, or null
, the request
- * encoding is used. If that is also not specified, or null
,
+ * individual part. When not specified, or {@code null}, the request
+ * encoding is used. If that is also not specified, or {@code null},
* the platform default encoding is used.
*
* @param encoding The encoding used to read part headers.
@@ -294,11 +294,11 @@ public void setHeaderEncoding(String encoding) {
/**
* Processes an RFC 1867
- * compliant multipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param req The servlet request to be parsed.
*
- * @return A list of FileItem
instances parsed from the
+ * @return A list of {@code FileItem} instances parsed from the
* request, in the order that they were transmitted.
*
* @throws FileUploadException if there are problems reading/parsing
@@ -314,11 +314,11 @@ public Listmultipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param ctx The context for the request to be parsed.
*
- * @return An iterator to instances of FileItemStream
+ * @return An iterator to instances of {@code FileItemStream}
* parsed from the request, in the order that they were
* transmitted.
*
@@ -340,11 +340,11 @@ public FileItemIterator getItemIterator(RequestContext ctx)
/**
* Processes an RFC 1867
- * compliant multipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param ctx The context for the request to be parsed.
*
- * @return A list of FileItem
instances parsed from the
+ * @return A list of {@code FileItem} instances parsed from the
* request, in the order that they were transmitted.
*
* @throws FileUploadException if there are problems reading/parsing
@@ -404,11 +404,11 @@ public Listmultipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param ctx The context for the request to be parsed.
*
- * @return A map of FileItem
instances parsed from the request.
+ * @return A map of {@code FileItem} instances parsed from the request.
*
* @throws FileUploadException if there are problems reading/parsing
* the request or storing files.
@@ -438,7 +438,7 @@ public MapContent-type
header.
+ * Retrieves the boundary from the {@code Content-type} header.
*
* @param contentType The value of the content type header from which to
* extract the boundary value.
@@ -465,12 +465,12 @@ protected byte[] getBoundary(String contentType) {
}
/**
- * Retrieves the file name from the Content-disposition
+ * Retrieves the file name from the {@code Content-disposition}
* header.
*
- * @param headers A Map
containing the HTTP request headers.
+ * @param headers A {@code Map} containing the HTTP request headers.
*
- * @return The file name for the current encapsulation
.
+ * @return The file name for the current {@code encapsulation}.
* @deprecated 1.2.1 Use {@link #getFileName(FileItemHeaders)}.
*/
@Deprecated
@@ -479,12 +479,12 @@ protected String getFileName(MapContent-disposition
+ * Retrieves the file name from the {@code Content-disposition}
* header.
*
* @param headers The HTTP headers object.
*
- * @return The file name for the current encapsulation
.
+ * @return The file name for the current {@code encapsulation}.
*/
protected String getFileName(FileItemHeaders headers) {
return getFileName(headers.getHeader(CONTENT_DISPOSITION));
@@ -521,12 +521,12 @@ private String getFileName(String pContentDisposition) {
}
/**
- * Retrieves the field name from the Content-disposition
+ * Retrieves the field name from the {@code Content-disposition}
* header.
*
- * @param headers A Map
containing the HTTP request headers.
+ * @param headers A {@code Map} containing the HTTP request headers.
*
- * @return The field name for the current encapsulation
.
+ * @return The field name for the current {@code encapsulation}.
*/
protected String getFieldName(FileItemHeaders headers) {
return getFieldName(headers.getHeader(CONTENT_DISPOSITION));
@@ -555,12 +555,12 @@ private String getFieldName(String pContentDisposition) {
}
/**
- * Retrieves the field name from the Content-disposition
+ * Retrieves the field name from the {@code Content-disposition}
* header.
*
- * @param headers A Map
containing the HTTP request headers.
+ * @param headers A {@code Map} containing the HTTP request headers.
*
- * @return The field name for the current encapsulation
.
+ * @return The field name for the current {@code encapsulation}.
* @deprecated 1.2.1 Use {@link #getFieldName(FileItemHeaders)}.
*/
@Deprecated
@@ -571,12 +571,12 @@ protected String getFieldName(MapMap
containing the HTTP request
+ * @param headers A {@code Map} containing the HTTP request
* headers.
* @param isFormField Whether or not this item is a form field, as
* opposed to a file.
*
- * @return A newly created FileItem
instance.
+ * @return A newly created {@code FileItem} instance.
*
* @throws FileUploadException if an error occurs.
* @deprecated 1.2 This method is no longer used in favour of
@@ -593,16 +593,16 @@ protected FileItem createItem(Mapheader-part
and returns as key/value
+ * header-part
of the current
- * encapsulation
.
+ * @param headerPart The {@code header-part} of the current
+ * {@code encapsulation}.
*
- * @return A Map
containing the parsed HTTP request headers.
+ * @return A {@code Map} containing the parsed HTTP request headers.
*/
protected FileItemHeaders getParsedHeaders(String headerPart) {
final int len = headerPart.length();
@@ -646,16 +646,16 @@ protected FileItemHeadersImpl newFileItemHeaders() {
}
/**
- * header-part
and returns as key/value
+ * header-part
of the current
- * encapsulation
.
+ * @param headerPart The {@code header-part} of the current
+ * {@code encapsulation}.
*
- * @return A Map
containing the parsed HTTP request headers.
+ * @return A {@code Map} containing the parsed HTTP request headers.
* @deprecated 1.2.1 Use {@link #getParsedHeaders(String)}
*/
@Deprecated
@@ -718,7 +718,7 @@ private void parseHeaderLine(FileItemHeadersImpl headers, String header) {
* Returns the header with the specified name from the supplied map. The
* header lookup is case-insensitive.
*
- * @param headers A Map
containing the HTTP request headers.
+ * @param headers A {@code Map} containing the HTTP request headers.
* @param name The name of the header to return.
*
* @return The value of specified header, or a comma-separated list if
@@ -1196,7 +1196,7 @@ public static class FileUploadIOException extends IOException {
private final FileUploadException cause;
/**
- * Creates a FileUploadIOException
with the
+ * Creates a {@code FileUploadIOException} with the
* given cause.
*
* @param pCause The exceptions cause, if any, or null.
@@ -1230,7 +1230,7 @@ public static class InvalidContentTypeException
private static final long serialVersionUID = -9073026332015646668L;
/**
- * Constructs a InvalidContentTypeException
with no
+ * Constructs a {@code InvalidContentTypeException} with no
* detail message.
*/
public InvalidContentTypeException() {
@@ -1238,7 +1238,7 @@ public InvalidContentTypeException() {
}
/**
- * Constructs an InvalidContentTypeException
with
+ * Constructs an {@code InvalidContentTypeException} with
* the specified detail message.
*
* @param message The detail message.
@@ -1248,7 +1248,7 @@ public InvalidContentTypeException(String message) {
}
/**
- * Constructs an InvalidContentTypeException
with
+ * Constructs an {@code InvalidContentTypeException} with
* the specified detail message and cause.
*
* @param msg The detail message.
@@ -1375,7 +1375,7 @@ public static class UnknownSizeException
private static final long serialVersionUID = 7062279004812015273L;
/**
- * Constructs a UnknownSizeException
with no
+ * Constructs a {@code UnknownSizeException} with no
* detail message.
*/
public UnknownSizeException() {
@@ -1383,7 +1383,7 @@ public UnknownSizeException() {
}
/**
- * Constructs an UnknownSizeException
with
+ * Constructs an {@code UnknownSizeException} with
* the specified detail message.
*
* @param message The detail message.
@@ -1425,7 +1425,7 @@ public SizeLimitExceededException(String message) {
}
/**
- * Constructs a SizeExceededException
with
+ * Constructs a {@code SizeExceededException} with
* the specified detail message, and actual and permitted sizes.
*
* @param message The detail message.
@@ -1461,7 +1461,7 @@ public static class FileSizeLimitExceededException
private String fieldName;
/**
- * Constructs a SizeExceededException
with
+ * Constructs a {@code SizeExceededException} with
* the specified detail message, and actual and permitted sizes.
*
* @param message The detail message.
diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadException.java b/src/main/java/org/apache/commons/fileupload/FileUploadException.java
index 3c39fe1f00..3c4e9a7821 100644
--- a/src/main/java/org/apache/commons/fileupload/FileUploadException.java
+++ b/src/main/java/org/apache/commons/fileupload/FileUploadException.java
@@ -37,14 +37,14 @@ public class FileUploadException extends Exception {
private final Throwable cause;
/**
- * Constructs a new FileUploadException
without message.
+ * Constructs a new {@code FileUploadException} without message.
*/
public FileUploadException() {
this(null, null);
}
/**
- * Constructs a new FileUploadException
with specified detail
+ * Constructs a new {@code FileUploadException} with specified detail
* message.
*
* @param msg the error message.
@@ -54,7 +54,7 @@ public FileUploadException(final String msg) {
}
/**
- * Creates a new FileUploadException
with the given
+ * Creates a new {@code FileUploadException} with the given
* detail message and cause.
*
* @param msg The exceptions detail message.
@@ -68,7 +68,7 @@ public FileUploadException(String msg, Throwable cause) {
/**
* Prints this throwable and its backtrace to the specified print stream.
*
- * @param stream PrintStream
to use for output
+ * @param stream {@code PrintStream} to use for output
*/
@Override
public void printStackTrace(PrintStream stream) {
@@ -83,7 +83,7 @@ public void printStackTrace(PrintStream stream) {
* Prints this throwable and its backtrace to the specified
* print writer.
*
- * @param writer PrintWriter
to use for output
+ * @param writer {@code PrintWriter} to use for output
*/
@Override
public void printStackTrace(PrintWriter writer) {
diff --git a/src/main/java/org/apache/commons/fileupload/MultipartStream.java b/src/main/java/org/apache/commons/fileupload/MultipartStream.java
index 2c58e7e413..09535c515d 100644
--- a/src/main/java/org/apache/commons/fileupload/MultipartStream.java
+++ b/src/main/java/org/apache/commons/fileupload/MultipartStream.java
@@ -171,7 +171,7 @@ private void notifyListener() {
public static final byte DASH = 0x2D;
/**
- * The maximum length of header-part
that will be
+ * The maximum length of {@code header-part} that will be
* processed (10 kilobytes = 10240 bytes.).
*/
public static final int HEADER_PART_SIZE_MAX = 10240;
@@ -182,25 +182,25 @@ private void notifyListener() {
protected static final int DEFAULT_BUFSIZE = 4096;
/**
- * A byte sequence that marks the end of header-part
- * (CRLFCRLF
).
+ * A byte sequence that marks the end of {@code header-part}
+ * ({@code CRLFCRLF}).
*/
protected static final byte[] HEADER_SEPARATOR = {CR, LF, CR, LF};
/**
* A byte sequence that that follows a delimiter that will be
- * followed by an encapsulation (CRLF
).
+ * followed by an encapsulation ({@code CRLF}).
*/
protected static final byte[] FIELD_SEPARATOR = {CR, LF};
/**
* A byte sequence that that follows a delimiter of the last
- * encapsulation in the stream (--
).
+ * encapsulation in the stream ({@code --}).
*/
protected static final byte[] STREAM_TERMINATOR = {DASH, DASH};
/**
- * A byte sequence that precedes a boundary (CRLF--
).
+ * A byte sequence that precedes a boundary ({@code CRLF--}).
*/
protected static final byte[] BOUNDARY_PREFIX = {CR, LF, DASH, DASH};
@@ -212,7 +212,7 @@ private void notifyListener() {
private final InputStream input;
/**
- * The length of the boundary token plus the leading CRLF--
.
+ * The length of the boundary token plus the leading {@code CRLF--}.
*/
private int boundaryLength;
@@ -280,7 +280,7 @@ public MultipartStream() {
}
/**
- * MultipartStream
with a custom size buffer
+ * InputStream
to serve as a data source.
+ * @param input The {@code InputStream} to serve as a data source.
* @param boundary The token used for dividing the stream into
- * encapsulations
.
+ * {@code encapsulations}.
* @param bufSize The size of the buffer to be used, in bytes.
*
* @deprecated 1.2.1 Use {@link #MultipartStream(InputStream, byte[], int,
@@ -302,16 +302,16 @@ public MultipartStream(InputStream input, byte[] boundary, int bufSize) {
}
/**
- * MultipartStream
with a custom size buffer.
+ * InputStream
to serve as a data source.
+ * @param input The {@code InputStream} to serve as a data source.
* @param boundary The token used for dividing the stream into
- * encapsulations
.
+ * {@code encapsulations}.
* @param bufSize The size of the buffer to be used, in bytes.
* @param pNotifier The notifier, which is used for calling the
* progress listener, if any.
@@ -356,11 +356,11 @@ public MultipartStream(InputStream input,
}
/**
- * MultipartStream
with a default size buffer.
+ * InputStream
to serve as a data source.
+ * @param input The {@code InputStream} to serve as a data source.
* @param boundary The token used for dividing the stream into
- * encapsulations
.
+ * {@code encapsulations}.
* @param pNotifier An object for calling the progress listener, if any.
*
*
@@ -373,11 +373,11 @@ public MultipartStream(InputStream input,
}
/**
- * MultipartStream
with a default size buffer.
+ * InputStream
to serve as a data source.
+ * @param input The {@code InputStream} to serve as a data source.
* @param boundary The token used for dividing the stream into
- * encapsulations
.
+ * {@code encapsulations}.
*
* @deprecated 1.2.1 Use {@link #MultipartStream(InputStream, byte[], int,
* ProgressNotifier)}.
@@ -392,7 +392,7 @@ public MultipartStream(InputStream input,
/**
* Retrieves the character encoding used when reading the headers of an
- * individual part. When not specified, or null
, the platform
+ * individual part. When not specified, or {@code null}, the platform
* default encoding is used.
*
* @return The encoding used to read part headers.
@@ -403,7 +403,7 @@ public String getHeaderEncoding() {
/**
* Specifies the character encoding to be used when reading the headers of
- * individual parts. When not specified, or null
, the platform
+ * individual parts. When not specified, or {@code null}, the platform
* default encoding is used.
*
* @param encoding The encoding used to read part headers.
@@ -413,7 +413,7 @@ public void setHeaderEncoding(String encoding) {
}
/**
- * Reads a byte from the buffer
, and refills it as
+ * Reads a byte from the {@code buffer}, and refills it as
* necessary.
*
* @return The next byte from the input stream.
@@ -438,11 +438,11 @@ public byte readByte() throws IOException {
}
/**
- * Skips a boundary
token, and checks whether more
- * encapsulations
are contained in the stream.
+ * Skips a {@code boundary} token, and checks whether more
+ * {@code encapsulations} are contained in the stream.
*
- * @return true
if there are more encapsulations in
- * this stream; false
otherwise.
+ * @return {@code true} if there are more encapsulations in
+ * this stream; {@code false} otherwise.
*
* @throws FileUploadIOException if the bytes read from the stream exceeded the size limits
* @throws MalformedStreamException if the stream ends unexpectedly or
@@ -490,7 +490,7 @@ public boolean readBoundary()
* required
+ * boundary
+ * @throws IllegalBoundaryException if the {@code boundary}
* has a different length than the one
* being currently parsed.
*/
@@ -539,17 +539,17 @@ private void computeBoundaryTable() {
}
/**
- * header-part
of the current
- * encapsulation
.
+ * CRLF
marker. Parsing is left to the
+ * trailing {@code CRLF} marker. Parsing is left to the
* application.
*
* header-part
of the current encapsulation.
+ * @return The {@code header-part} of the current encapsulation.
*
* @throws FileUploadIOException if the bytes read from the stream exceeded the size limits.
* @throws MalformedStreamException if the stream ends unexpectedly.
@@ -599,16 +599,16 @@ public String readHeaders() throws FileUploadIOException, MalformedStreamExcepti
}
/**
- * body-data
from the current
- * encapsulation
and writes its contents into the
- * output Stream
.
+ * Stream
to write data into. May
+ * @param output The {@code Stream} to write data into. May
* be null, in which case this method is equivalent
* to {@link #discardBodyData()}.
*
@@ -631,8 +631,8 @@ ItemInputStream newInputStream() {
}
/**
- * body-data
from the current
- * encapsulation
and discards it.
+ * encapsulation
.
+ * Finds the beginning of the first {@code encapsulation}.
*
- * @return true
if an encapsulation
was found in
+ * @return {@code true} if an {@code encapsulation} was found in
* the stream.
*
* @throws IOException if an i/o error occurs.
@@ -679,15 +679,15 @@ public boolean skipPreamble() throws IOException {
}
/**
- * Compares count
first bytes in the arrays
- * a
and b
.
+ * Compares {@code count} first bytes in the arrays
+ * {@code a} and {@code b}.
*
* @param a The first array to compare.
* @param b The second array to compare.
* @param count How many bytes should be compared.
*
- * @return true
if count
first bytes in arrays
- * a
and b
are equal.
+ * @return {@code true} if {@code count} first bytes in arrays
+ * {@code a} and {@code b} are equal.
*/
public static boolean arrayequals(byte[] a,
byte[] b,
@@ -701,14 +701,14 @@ public static boolean arrayequals(byte[] a,
}
/**
- * Searches for a byte of specified value in the buffer
,
- * starting at the specified position
.
+ * Searches for a byte of specified value in the {@code buffer},
+ * starting at the specified {@code position}.
*
* @param value The value to find.
* @param pos The starting position for searching.
*
* @return The position of byte found, counting from beginning of the
- * buffer
, or -1
if not found.
+ * {@code buffer}, or {@code -1} if not found.
*/
protected int findByte(byte value,
int pos) {
@@ -722,11 +722,11 @@ protected int findByte(byte value,
}
/**
- * Searches for the boundary
in the buffer
- * region delimited by head
and tail
.
+ * Searches for the {@code boundary} in the {@code buffer}
+ * region delimited by {@code head} and {@code tail}.
*
* @return The position of the boundary found, counting from the
- * beginning of the buffer
, or -1
if
+ * beginning of the {@code buffer}, or {@code -1} if
* not found.
*/
protected int findSeparator() {
@@ -759,7 +759,7 @@ public static class MalformedStreamException extends IOException {
private static final long serialVersionUID = 6466926458059796677L;
/**
- * Constructs a MalformedStreamException
with no
+ * Constructs a {@code MalformedStreamException} with no
* detail message.
*/
public MalformedStreamException() {
@@ -767,7 +767,7 @@ public MalformedStreamException() {
}
/**
- * Constructs an MalformedStreamException
with
+ * Constructs an {@code MalformedStreamException} with
* the specified detail message.
*
* @param message The detail message.
@@ -789,7 +789,7 @@ public static class IllegalBoundaryException extends IOException {
private static final long serialVersionUID = -161533165102632918L;
/**
- * Constructs an IllegalBoundaryException
with no
+ * Constructs an {@code IllegalBoundaryException} with no
* detail message.
*/
public IllegalBoundaryException() {
@@ -797,7 +797,7 @@ public IllegalBoundaryException() {
}
/**
- * Constructs an IllegalBoundaryException
with
+ * Constructs an {@code IllegalBoundaryException} with
* the specified detail message.
*
* @param message The detail message.
diff --git a/src/main/java/org/apache/commons/fileupload/ParameterParser.java b/src/main/java/org/apache/commons/fileupload/ParameterParser.java
index e6454584cf..e84931a7b6 100644
--- a/src/main/java/org/apache/commons/fileupload/ParameterParser.java
+++ b/src/main/java/org/apache/commons/fileupload/ParameterParser.java
@@ -31,7 +31,7 @@
* Parameter values are optional and can be omitted.
*
* param1 = value; param2 = "anything goes; really"; param3
+ * {@code param1 = value; param2 = "anything goes; really"; param3}
* null
if
+ * The content type passed by the browser, or {@code null} if
* not defined.
*/
private final String contentType;
@@ -161,15 +161,15 @@ public class DiskFileItem
// ----------------------------------------------------------- Constructors
/**
- * Constructs a new DiskFileItem
instance.
+ * Constructs a new {@code DiskFileItem} instance.
*
* @param fieldName The name of the form field.
* @param contentType The content type passed by the browser or
- * null
if not specified.
+ * {@code null} if not specified.
* @param isFormField Whether or not this item is a plain form field, as
* opposed to a file upload.
* @param fileName The original filename in the user's filesystem, or
- * null
if not specified.
+ * {@code null} if not specified.
* @param sizeThreshold The threshold, in bytes, below which items will be
* retained in memory and above which they will be
* stored as a file.
@@ -213,10 +213,10 @@ public InputStream getInputStream()
}
/**
- * Returns the content type passed by the agent or null
if
+ * Returns the content type passed by the agent or {@code null} if
* not defined.
*
- * @return The content type passed by the agent or null
if
+ * @return The content type passed by the agent or {@code null} if
* not defined.
*/
@Override
@@ -225,10 +225,10 @@ public String getContentType() {
}
/**
- * Returns the content charset passed by the agent or null
if
+ * Returns the content charset passed by the agent or {@code null} if
* not defined.
*
- * @return The content charset passed by the agent or null
if
+ * @return The content charset passed by the agent or {@code null} if
* not defined.
*/
public String getCharSet() {
@@ -259,8 +259,8 @@ public String getName() {
* Provides a hint as to whether or not the file contents will be read
* from memory.
*
- * @return true
if the file contents will be read
- * from memory; false
otherwise.
+ * @return {@code true} if the file contents will be read
+ * from memory; {@code false} otherwise.
*/
@Override
public boolean isInMemory() {
@@ -376,7 +376,7 @@ public String getString() {
* method renames a temporary file, that file will no longer be available
* to copy or rename again at a later time.
*
- * @param file The File
into which the uploaded item should
+ * @param file The {@code File} into which the uploaded item should
* be stored.
*
* @throws Exception if an error occurs.
@@ -420,7 +420,7 @@ public void write(File file) throws Exception {
/**
* Deletes the underlying storage for a file item, including deleting any
* associated temporary disk file. Although this storage will be deleted
- * automatically when the FileItem
instance is garbage
+ * automatically when the {@code FileItem} instance is garbage
* collected, this method can be used to ensure that this is done at an
* earlier time, thus preserving system resources.
*/
@@ -461,11 +461,11 @@ public void setFieldName(String fieldName) {
}
/**
- * Determines whether or not a FileItem
instance represents
+ * Determines whether or not a {@code FileItem} instance represents
* a simple form field.
*
- * @return true
if the instance represents a simple form
- * field; false
if it represents an uploaded file.
+ * @return {@code true} if the instance represents a simple form
+ * field; {@code false} if it represents an uploaded file.
*
* @see #setFormField(boolean)
*
@@ -476,11 +476,11 @@ public boolean isFormField() {
}
/**
- * Specifies whether or not a FileItem
instance represents
+ * Specifies whether or not a {@code FileItem} instance represents
* a simple form field.
*
- * @param state true
if the instance represents a simple form
- * field; false
if it represents an uploaded file.
+ * @param state {@code true} if the instance represents a simple form
+ * field; {@code false} if it represents an uploaded file.
*
* @see #isFormField()
*
@@ -512,16 +512,16 @@ public OutputStream getOutputStream()
// --------------------------------------------------------- Public methods
/**
- * Returns the {@link java.io.File} object for the FileItem
's
+ * Returns the {@link java.io.File} object for the {@code FileItem}'s
* data's temporary location on the disk. Note that for
- * FileItem
s that have their data stored in memory,
- * this method will return null
. When handling large
+ * {@code FileItem}s that have their data stored in memory,
+ * this method will return {@code null}. When handling large
* files, you can use {@link java.io.File#renameTo(java.io.File)} to
* move the file to new location without copying the data, if the
* source and destination locations reside within the same logical
* volume.
*
- * @return The data file, or null
if the data is stored in
+ * @return The data file, or {@code null} if the data is stored in
* memory.
*/
public File getStoreLocation() {
@@ -554,7 +554,7 @@ protected void finalize() {
/**
* Creates and returns a {@link java.io.File File} representing a uniquely
* named temporary file in the configured repository path. The lifetime of
- * the file is tied to the lifetime of the FileItem
instance;
+ * the file is tied to the lifetime of the {@code FileItem} instance;
* the file will be deleted when the instance is garbage collected.
*
*
* System.getProperty("java.io.tmpdir")
.javax.servlet.context.tempdir
+ * by the ServletContext attribute {@code javax.servlet.context.tempdir}
* may be used.
* true
if this is a plain form field;
- * false
otherwise.
+ * @param isFormField {@code true} if this is a plain form field;
+ * {@code false} otherwise.
* @param fileName The name of the uploaded file, if any, as supplied
* by the browser or other client.
*
diff --git a/src/main/java/org/apache/commons/fileupload/package-info.java b/src/main/java/org/apache/commons/fileupload/package-info.java
index 9e3070476e..1821daf3dd 100644
--- a/src/main/java/org/apache/commons/fileupload/package-info.java
+++ b/src/main/java/org/apache/commons/fileupload/package-info.java
@@ -67,7 +67,7 @@
*
* String
. Before calling the getString
method,
+ * {@code String}. Before calling the {@code getString} method,
* the data may have been in memory or on disk depending on its size. The
* second file we assume it will be large and therefore never explicitly
* load it into memory, though if it is less than 4096 bytes it will be
diff --git a/src/main/java/org/apache/commons/fileupload/portlet/PortletFileUpload.java b/src/main/java/org/apache/commons/fileupload/portlet/PortletFileUpload.java
index 8192304b24..7898a6dfa3 100644
--- a/src/main/java/org/apache/commons/fileupload/portlet/PortletFileUpload.java
+++ b/src/main/java/org/apache/commons/fileupload/portlet/PortletFileUpload.java
@@ -33,7 +33,7 @@
* multipart/mixed
encoding type, as specified by
+ * {@code multipart/mixed} encoding type, as specified by
* RFC 1867. Use
* {@link org.apache.commons.fileupload.servlet.ServletFileUpload
* #parseRequest(javax.servlet.http.HttpServletRequest)} to acquire a list
@@ -56,8 +56,8 @@ public class PortletFileUpload extends FileUpload {
*
* @param request The portlet request to be evaluated. Must be non-null.
*
- * @return true
if the request is multipart;
- * false
otherwise.
+ * @return {@code true} if the request is multipart;
+ * {@code false} otherwise.
*/
public static final boolean isMultipartContent(ActionRequest request) {
return FileUploadBase.isMultipartContent(
@@ -68,7 +68,7 @@ public static final boolean isMultipartContent(ActionRequest request) {
/**
* Constructs an uninitialised instance of this class. A factory must be
- * configured, using setFileItemFactory()
, before attempting
+ * configured, using {@code setFileItemFactory()}, before attempting
* to parse requests.
*
* @see FileUpload#FileUpload(FileItemFactory)
@@ -79,7 +79,7 @@ public PortletFileUpload() {
/**
* Constructs an instance of this class which uses the supplied factory to
- * create FileItem
instances.
+ * create {@code FileItem} instances.
*
* @see FileUpload#FileUpload()
* @param fileItemFactory The factory to use for creating file items.
@@ -92,11 +92,11 @@ public PortletFileUpload(FileItemFactory fileItemFactory) {
/**
* Processes an RFC 1867
- * compliant multipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param request The portlet request to be parsed.
*
- * @return A list of FileItem
instances parsed from the
+ * @return A list of {@code FileItem} instances parsed from the
* request, in the order that they were transmitted.
*
* @throws FileUploadException if there are problems reading/parsing
@@ -109,11 +109,11 @@ public Listmultipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param request The portlet request to be parsed.
*
- * @return A map of FileItem
instances parsed from the request.
+ * @return A map of {@code FileItem} instances parsed from the request.
*
* @throws FileUploadException if there are problems reading/parsing
* the request or storing files.
@@ -127,11 +127,11 @@ public Mapmultipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param request The portlet request to be parsed.
*
- * @return An iterator to instances of FileItemStream
+ * @return An iterator to instances of {@code FileItemStream}
* parsed from the request, in the order that they were
* transmitted.
*
diff --git a/src/main/java/org/apache/commons/fileupload/portlet/package-info.java b/src/main/java/org/apache/commons/fileupload/portlet/package-info.java
index e39b6ca15f..7a3104f4f6 100644
--- a/src/main/java/org/apache/commons/fileupload/portlet/package-info.java
+++ b/src/main/java/org/apache/commons/fileupload/portlet/package-info.java
@@ -20,7 +20,7 @@
* An implementation of
* {@link org.apache.commons.fileupload.FileUpload FileUpload}
* for use in portlets conforming to JSR 168. This implementation requires
- * only access to the portlet's current ActionRequest
instance,
+ * only access to the portlet's current {@code ActionRequest} instance,
* and a suitable
* {@link org.apache.commons.fileupload.FileItemFactory FileItemFactory}
* implementation, such as
diff --git a/src/main/java/org/apache/commons/fileupload/servlet/ServletFileUpload.java b/src/main/java/org/apache/commons/fileupload/servlet/ServletFileUpload.java
index c0e2b5e447..9863b20530 100644
--- a/src/main/java/org/apache/commons/fileupload/servlet/ServletFileUpload.java
+++ b/src/main/java/org/apache/commons/fileupload/servlet/ServletFileUpload.java
@@ -33,7 +33,7 @@
* multipart/mixed
encoding type, as specified by
+ * {@code multipart/mixed} encoding type, as specified by
* RFC 1867. Use {@link
* #parseRequest(HttpServletRequest)} to acquire a list of {@link
* org.apache.commons.fileupload.FileItem}s associated with a given HTML
@@ -58,8 +58,8 @@ public class ServletFileUpload extends FileUpload {
*
* @param request The servlet request to be evaluated. Must be non-null.
*
- * @return true
if the request is multipart;
- * false
otherwise.
+ * @return {@code true} if the request is multipart;
+ * {@code false} otherwise.
*/
public static final boolean isMultipartContent(
HttpServletRequest request) {
@@ -73,7 +73,7 @@ public static final boolean isMultipartContent(
/**
* Constructs an uninitialised instance of this class. A factory must be
- * configured, using setFileItemFactory()
, before attempting
+ * configured, using {@code setFileItemFactory()}, before attempting
* to parse requests.
*
* @see FileUpload#FileUpload(FileItemFactory)
@@ -84,7 +84,7 @@ public ServletFileUpload() {
/**
* Constructs an instance of this class which uses the supplied factory to
- * create FileItem
instances.
+ * create {@code FileItem} instances.
*
* @see FileUpload#FileUpload()
* @param fileItemFactory The factory to use for creating file items.
@@ -97,11 +97,11 @@ public ServletFileUpload(FileItemFactory fileItemFactory) {
/**
* Processes an RFC 1867
- * compliant multipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param request The servlet request to be parsed.
*
- * @return A list of FileItem
instances parsed from the
+ * @return A list of {@code FileItem} instances parsed from the
* request, in the order that they were transmitted.
*
* @throws FileUploadException if there are problems reading/parsing
@@ -115,11 +115,11 @@ public Listmultipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param request The servlet request to be parsed.
*
- * @return A map of FileItem
instances parsed from the request.
+ * @return A map of {@code FileItem} instances parsed from the request.
*
* @throws FileUploadException if there are problems reading/parsing
* the request or storing files.
@@ -133,11 +133,11 @@ public Mapmultipart/form-data
stream.
+ * compliant {@code multipart/form-data} stream.
*
* @param request The servlet request to be parsed.
*
- * @return An iterator to instances of FileItemStream
+ * @return An iterator to instances of {@code FileItemStream}
* parsed from the request, in the order that they were
* transmitted.
*
diff --git a/src/main/java/org/apache/commons/fileupload/servlet/package-info.java b/src/main/java/org/apache/commons/fileupload/servlet/package-info.java
index ae41685458..e9a085fc3c 100644
--- a/src/main/java/org/apache/commons/fileupload/servlet/package-info.java
+++ b/src/main/java/org/apache/commons/fileupload/servlet/package-info.java
@@ -20,7 +20,7 @@
* An implementation of
* {@link org.apache.commons.fileupload.FileUpload FileUpload}
* for use in servlets conforming to JSR 53. This implementation requires
- * only access to the servlet's current HttpServletRequest
+ * only access to the servlet's current {@code HttpServletRequest}
* instance, and a suitable
* {@link org.apache.commons.fileupload.FileItemFactory FileItemFactory}
* implementation, such as
diff --git a/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java b/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java
index 2845e32f9e..1d1abbb2ee 100644
--- a/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java
+++ b/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java
@@ -40,8 +40,8 @@ public class FileItemHeadersImpl implements FileItemHeaders, Serializable {
private static final long serialVersionUID = -4455695752627032559L;
/**
- * Map of String
keys to a List
of
- * String
instances.
+ * Map of {@code String} keys to a {@code List} of
+ * {@code String} instances.
*/
private final Mapint
in the range
- * 0
to 255
. If no byte is available
+ * byte is returned as an {@code int} in the range
+ * {@code 0} to {@code 255}. If no byte is available
* because the end of the stream has been reached, the value
- * -1
is returned. This method blocks until input data
+ * {@code -1} is returned. This method blocks until input data
* is available, the end of the stream is detected, or an exception
* is thrown.
* in.read()
and returns the result.
+ * simply performs {@code in.read()} and returns the result.
*
- * @return the next byte of data, or -1
if the end of the
+ * @return the next byte of data, or {@code -1} if the end of the
* stream is reached.
* @throws IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
@@ -105,25 +105,25 @@ public int read() throws IOException {
}
/**
- * Reads up to len
bytes of data from this input stream
- * into an array of bytes. If len
is not zero, the method
+ * Reads up to {@code len} bytes of data from this input stream
+ * into an array of bytes. If {@code len} is not zero, the method
* blocks until some input is available; otherwise, no
- * bytes are read and 0
is returned.
+ * bytes are read and {@code 0} is returned.
* in.read(b, off, len)
+ * This method simply performs {@code in.read(b, off, len)}
* and returns the result.
*
* @param b the buffer into which the data is read.
* @param off The start offset in the destination array
- * b
.
+ * {@code b}.
* @param len the maximum number of bytes read.
* @return the total number of bytes read into the buffer, or
- * -1
if there is no more data because the end of
+ * {@code -1} if there is no more data because the end of
* the stream has been reached.
- * @throws NullPointerException If b
is null
.
- * @throws IndexOutOfBoundsException If off
is negative,
- * len
is negative, or len
is greater than
- * b.length - off
+ * @throws NullPointerException If {@code b} is {@code null}.
+ * @throws IndexOutOfBoundsException If {@code off} is negative,
+ * {@code len} is negative, or {@code len} is greater than
+ * {@code b.length - off}
* @throws IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
@@ -152,7 +152,7 @@ public boolean isClosed() throws IOException {
* Closes this input stream and releases any system resources
* associated with the stream.
* This
- * method simply performs in.close()
.
+ * method simply performs {@code in.close()}.
*
* @throws IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
diff --git a/src/site/fml/faq.fml b/src/site/fml/faq.fml
index 3b80c774d0..cf0a018deb 100644
--- a/src/site/fml/faq.fml
+++ b/src/site/fml/faq.fml
@@ -59,7 +59,7 @@
jar in your classpath. FileUpload depends on IO (see
dependencies) - you can tell if
this is the case if the missing class is within the
- org.apache.commons.io
package. FileUpload
class is used for accessing the
+ Again, the {@code FileUpload} class is used for accessing the
form fields and fields in the order in which they have been sent
- by the client. However, the FileItemFactory
is completely
+ by the client. However, the {@code FileItemFactory} is completely
ignored.
FileItem
interface,
+ items. Each such item implements the {@code FileItem} interface,
regardless of its underlying implementation.
InputStream
to access its data. On the
+ and can provide an {@code InputStream} to access its data. On the
other hand, you may need to process items differently, depending upon
whether the item is a regular form field - that is, the data came from
an ordinary text box or similar HTML field - or an uploaded file. The
- FileItem
interface provides the methods to make such a
+ {@code FileItem} interface provides the methods to make such a
determination, and to access the data in the most appropriate manner.
FileItemFactory
.
+ FileUpload creates new file items using a {@code FileItemFactory}.
This is what gives FileUpload most of its flexibility. The factory has
ultimate control over how each item is created. The factory implementation
that currently ships with FileUpload stores the item's data in memory or
@@ -96,12 +96,12 @@
distinctions you should make as you read this document:
ServletFileUpload
class,
- substitute the PortletFileUpload
class.
+ Where you see references to the {@code ServletFileUpload} class,
+ substitute the {@code PortletFileUpload} class.
HttpServletRequest
class,
- substitute the ActionRequest
class.
+ Where you see references to the {@code HttpServletRequest} class,
+ substitute the {@code ActionRequest} class.
- The result of the parse is a List
of file items, each of
- which implements the FileItem
interface. Processing these
+ The result of the parse is a {@code List} of file items, each of
+ which implements the {@code FileItem} interface. Processing these
items is discussed below.
- Once the parse has completed, you will have a List
of file
+ Once the parse has completed, you will have a {@code List} of file
items that you need to process. In most cases, you will want to handle
file uploads differently from regular form fields, so you might process
the list like this:
@@ -220,7 +220,7 @@ while (iter.hasNext()) {
}]]>
For a regular form field, you will most likely be interested only in the
- name of the item, and its String
value. As you might expect,
+ name of the item, and its {@code String} value. As you might expect,
accessing these is very simple.
- Note that, in the default implementation of FileUpload, write()
+ Note that, in the default implementation of FileUpload, {@code write()}
will attempt to rename the file to the specified destination, if the data
is already in a temporary file. Actually copying the data is only done if
the the rename fails, for some reason, or if the data was in memory.
If you do need to access the uploaded data in memory, you need simply
- call the get()
method to obtain the data as an array of
+ call the {@code get()} method to obtain the data as an array of
bytes.
Such temporary files are deleted automatically, if they are no longer
- used (more precisely, if the corresponding instance of DiskFileItem
- is garbage collected. This is done silently by the org.apache.commons.io.FileCleanerTracker
+ used (more precisely, if the corresponding instance of {@code DiskFileItem}
+ is garbage collected. This is done silently by the {@code org.apache.commons.io.FileCleanerTracker}
class, which starts a reaper thread.
@@ -293,7 +293,7 @@ byte[] data = item.get();
a servlet environment, this is done by using a special servlet
context listener, called
FileCleanerCleanup.
- To do so, add a section like the following to your web.xml
:
+ To do so, add a section like the following to your {@code web.xml}:
The FileCleanerCleanup provides an instance of
- org.apache.commons.io.FileCleaningTracker
. This
+ {@code org.apache.commons.io.FileCleaningTracker}. This
instance must be used when creating a
- org.apache.commons.fileupload.disk.DiskFileItemFactory
.
+ {@code org.apache.commons.fileupload.disk.DiskFileItemFactory}.
This should be done by calling a method like the following:
To disable tracking of temporary files, you may set the
- FileCleaningTracker
to null. Consequently,
+ {@code FileCleaningTracker} to null. Consequently,
created files will no longer be tracked. In particular,
they will no longer be deleted automatically.
FileItemFactory
and returns it, obscuring
+ * Creates a new {@code FileItemFactory} and returns it, obscuring
* from the caller the underlying implementation of this interface.
*
* @param repository The directory within which temporary files will be
* created.
- * @return the new FileItemFactory
instance.
+ * @return the new {@code FileItemFactory} instance.
*/
protected FileItemFactory createFactory(File repository) {
return new DefaultFileItemFactory(threshold, repository);
From 7e2705cf6f980d54725ff0953b648b557e9583d3 Mon Sep 17 00:00:00 2001
From: Mark Thomas * Please see the FileUpload - * User Guide + * User Guide * for further details and examples of how to use this package. *
*/ diff --git a/src/main/java/org/apache/commons/fileupload/package-info.java b/src/main/java/org/apache/commons/fileupload/package-info.java index 3d983a786d..0ba376a4ad 100644 --- a/src/main/java/org/apache/commons/fileupload/package-info.java +++ b/src/main/java/org/apache/commons/fileupload/package-info.java @@ -78,7 +78,7 @@ * ** Please see the FileUpload - * User Guide + * User Guide * for further details and examples of how to use this package. *
*/ diff --git a/src/main/java/org/apache/commons/fileupload/servlet/package-info.java b/src/main/java/org/apache/commons/fileupload/servlet/package-info.java index e9a085fc3c..571d7f81ec 100644 --- a/src/main/java/org/apache/commons/fileupload/servlet/package-info.java +++ b/src/main/java/org/apache/commons/fileupload/servlet/package-info.java @@ -38,7 +38,7 @@ * ** Please see the FileUpload - * User Guide + * User Guide * for further details and examples of how to use this package. *
*/ From f4d1066825e5830475bfb16b3d97c884d62c7e40 Mon Sep 17 00:00:00 2001 From: Merbin J Anselm+ * @see RFC 2231 + * @see RFC 5987 + */ +public final class RFC2231Utility { + + private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray(); + + private static final byte[] HEX_DECODE = new byte[0x80]; + + // create a ASCII decoded array of Hexadecimal values + static { + for (int i = 0; i < HEX_DIGITS.length; i++) { + HEX_DECODE[HEX_DIGITS[i]] = (byte) i; + HEX_DECODE[Character.toLowerCase(HEX_DIGITS[i])] = (byte) i; + } + } + + /** + * Decode a string of text obtained from a HTTP header as per RFC 2231 + * + *
+ * Eg 1. {@code us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A} + * will be decoded to {@code This is ***fun***} + * + * Eg 2. {@code iso-8859-1'en'%A3%20rate} + * will be decoded to {@code £ rate} + * + * Eg 3. {@code UTF-8''%c2%a3%20and%20%e2%82%ac%20rates} + * will be decoded to {@code £ and € rates} + * + * @param encodedText - Text to be decoded has a format of {@code
* @see RFC 2231
* @see RFC 5987
*/
public final class RFC2231Utility {
-
+ /**
+ * The Hexadecimal values char array.
+ */
private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
-
- private static final byte[] HEX_DECODE = new byte[0x80];
+ /**
+ * The Hexadecimal representation of 127.
+ */
+ private static final byte MASK = 0x7f;
+ /**
+ * The Hexadecimal representation of 128.
+ */
+ private static final int MASK_128 = 0x80;
+ /**
+ * The Hexadecimal decode value.
+ */
+ private static final byte[] HEX_DECODE = new byte[MASK_128];
// create a ASCII decoded array of Hexadecimal values
static {
@@ -43,29 +56,36 @@ public final class RFC2231Utility {
}
}
+ /**
+ * Private constructor so that no instances can be created. This class
+ * contains only static utility methods.
+ */
+ private RFC2231Utility() {
+ }
+
/**
* Checks if Asterisk (*) at the end of parameter name to indicate,
- * if it has charset and language information to decode the value
- * @param paramName
+ * if it has charset and language information to decode the value.
+ * @param paramName The parameter, which is being checked.
* @return {@code true}, if encoded as per RFC 2231, {@code false} otherwise
*/
- public static boolean hasEncodedValue(String paramName) {
+ public static boolean hasEncodedValue(final String paramName) {
if (paramName != null) {
- return paramName.lastIndexOf("*") == (paramName.length() - 1);
+ return paramName.lastIndexOf('*') == (paramName.length() - 1);
}
return false;
}
/**
- * If {@code paramName} has Asterisk (*) at the end, it will be stripped off,
- * else the passed value will be returned
- * @param paramName
+ * If {@code paramName} has Asterisk (*) at the end, it will be stripped off,
+ * else the passed value will be returned.
+ * @param paramName The parameter, which is being inspected.
* @return stripped {@code paramName} of Asterisk (*), if RFC2231 encoded
*/
- public static String stripDelimiter(String paramName) {
+ public static String stripDelimiter(final String paramName) {
if (hasEncodedValue(paramName)) {
- StringBuilder paramBuilder = new StringBuilder(paramName);
- paramBuilder.deleteCharAt(paramName.lastIndexOf("*"));
+ final StringBuilder paramBuilder = new StringBuilder(paramName);
+ paramBuilder.deleteCharAt(paramName.lastIndexOf('*'));
return paramBuilder.toString();
}
return paramName;
@@ -84,42 +104,44 @@ public static String stripDelimiter(String paramName) {
* Eg 3. {@code UTF-8''%c2%a3%20and%20%e2%82%ac%20rates}
* will be decoded to {@code £ and € rates}
*
- * @param encodedText - Text to be decoded has a format of {@code
* RFC 5987 builds on RFC 2231, but has lesser scope like
* mandatory charset definition
* and no parameter continuation
*
- *
* @see RFC 2231
* @see RFC 5987
*/
@@ -93,14 +92,13 @@ public static String stripDelimiter(final String paramName) {
/**
* Decode a string of text obtained from a HTTP header as per RFC 2231
- *
- *
* Eg 1. {@code us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A}
* will be decoded to {@code This is ***fun***}
- *
* Eg 2. {@code iso-8859-1'en'%A3%20rate}
* will be decoded to {@code £ rate}
- *
* Eg 3. {@code UTF-8''%c2%a3%20and%20%e2%82%ac%20rates}
* will be decoded to {@code £ and € rates}
*
From 20daaa6d5651714698225df37a2cb9682d39c2d1 Mon Sep 17 00:00:00 2001
From: Mark Thomas