public abstract class AbstractAttachmentDownloadStrategy extends Object implements com.atlassian.plugin.servlet.DownloadStrategy
| Modifier and Type | Field and Description |
|---|---|
protected static String |
ATTACHMENT_DOWNLOAD_PATH_PREFIX |
protected static String |
THUMBNAIL_DOWNLOAD_PATH_PREFIX |
| Constructor and Description |
|---|
AbstractAttachmentDownloadStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
getDecodedPath(javax.servlet.http.HttpServletRequest request)
Retrieves the url decoded path of the attachment.
|
protected void |
handleDownloadResourceNotFoundException(javax.servlet.http.HttpServletResponse response) |
protected void |
handleUnauthorizedDownloadResourceException(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected static final String ATTACHMENT_DOWNLOAD_PATH_PREFIX
protected static final String THUMBNAIL_DOWNLOAD_PATH_PREFIX
protected String getDecodedPath(javax.servlet.http.HttpServletRequest request)
This operation is potentially problematic because it is possible that some web server in front of us already url decoded the URL before us. The apache httpd mod_jk module does that for instance. We cannot just pass the string as already decoded, because mod_jk by default just partially decodes the URL before forwarding it to Tomcat.
Double decoding is not an issue except for plus signs. '%2B' decodes to '+' which decodes to ' '. We therefore re-encode any plus sign again to safely decode the path (We encounter a '+' sign if mod_jk already decoded %2B).
In the case where no Apache is sitting in front of Tomcat it is not possible that the path contains a plus sign because Confluence escapes plus signs in the filename as '%2B' and escapes spaces as '%20'. Therefore we can assume that any plus character in the filename was caused by URL decoding by a web server in front of our Tomcat instance.
In order to keep backwards compability with existing old links, we only re-encode the '+' sign when the v2 api revision parameter is set.
See CONF-22338 for an issue that was caused by this.
request - protected void handleDownloadResourceNotFoundException(javax.servlet.http.HttpServletResponse response)
throws IOException
IOExceptionprotected void handleUnauthorizedDownloadResourceException(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws IOException
IOExceptionCopyright © 2003–2016 Atlassian. All rights reserved.