ASF Bugzilla – Attachment 26135 Details for
Bug 49811
[PATCH] Disable UrlRewriting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Updated patch
bug49811-tc6.patch (text/plain), 7.31 KB, created by
Mark Thomas
on 2010-10-07 06:56:09 UTC
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Mark Thomas
Created:
2010-10-07 06:56:09 UTC
Size:
7.31 KB
patch
obsolete
>Index: java/org/apache/catalina/Context.java >=================================================================== >--- java/org/apache/catalina/Context.java (revision 1005400) >+++ java/org/apache/catalina/Context.java (working copy) >@@ -325,6 +325,35 @@ > * @param docBase The new document root > */ > public void setDocBase(String docBase); >+ >+ >+ /** >+ * Is URL rewriting disabled? >+ * URL rewriting is an optional component of the servlet 2.5 specification. >+ * However if set to true this will be non-compliant with the specification >+ * as the specification requires that there <b>must</b> be a way to retain >+ * sessions if the client doesn't allow session cookies. >+ * >+ * @return true If URL rewriting is disabled. >+ * >+ * @see <a href="http://jcp.org/aboutJava/communityprocess/mrel/jsr154/index2.html">Servlet >+ * 2.5 Specification. Sections SRV.7.1.3 and SRV.7.1.4</a> >+ * @see javax.servlet.http.HttpServletResponse#encodeURL(String) encodeURL >+ * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(String) >+ * encodeRedirectURL >+ */ >+ public boolean isDisableURLRewriting(); >+ >+ /** >+ * Is URL rewriting disabled? >+ * URL rewriting is an optional component of the servlet 2.5 specification. >+ * However if set to true this will be non-compliant with the specification >+ * as the specification requires that there <b>must</b> be a way to retain >+ * sessions if the client doesn't allow session cookies. >+ * >+ * @param disable True to disable URL Rewriting. Default <b>false</b>. >+ */ >+ public void setDisableURLRewriting(boolean disable); > > > /** >Index: java/org/apache/catalina/connector/CoyoteAdapter.java >=================================================================== >--- java/org/apache/catalina/connector/CoyoteAdapter.java (revision 1005191) >+++ java/org/apache/catalina/connector/CoyoteAdapter.java (working copy) >@@ -462,6 +462,13 @@ > connector.getMapper().map(serverName, decodedURI, > request.getMappingData()); > request.setContext((Context) request.getMappingData().context); >+ >+ // Had to do this after the context was set. >+ // Unfortunately parseSessionId is still necessary as it >+ // affects the final URL. Safe as session cookies still >+ // haven't been parsed. >+ if (isURLRewritingDisabled(request)) >+ clearRequestedSessionURL(request); > request.setWrapper((Wrapper) request.getMappingData().wrapper); > > // Filter trace method >@@ -516,6 +523,13 @@ > return true; > } > >+ private boolean isURLRewritingDisabled(Request request) { >+ Context context = (Context) request.getMappingData().context; >+ if (context != null) >+ return (context.isDisableURLRewriting()); >+ else >+ return (false); >+ } > > /** > * Parse session id in URL. >@@ -560,19 +574,22 @@ > } > request.setRequestedSessionURL(true); > } catch (UnsupportedEncodingException uee) { >- // Make sure no session ID is returned >- request.setRequestedSessionId(null); >- request.setRequestedSessionURL(false); >+ clearRequestedSessionURL(request); > log.warn(sm.getString("coyoteAdapter.parseSession", enc), uee); > } > } else { >- request.setRequestedSessionId(null); >- request.setRequestedSessionURL(false); >+ clearRequestedSessionURL(request); > } > > } > > >+ private void clearRequestedSessionURL(Request request) { >+ request.setRequestedSessionId(null); >+ request.setRequestedSessionURL(false); >+ } >+ >+ > /** > * Parse session id in URL. > */ >Index: java/org/apache/catalina/connector/Response.java >=================================================================== >--- java/org/apache/catalina/connector/Response.java (revision 1005191) >+++ java/org/apache/catalina/connector/Response.java (working copy) >@@ -1479,12 +1479,14 @@ > * <li>The requested session ID was not received via a cookie > * <li>The specified URL points back to somewhere within the web > * application that is responding to this request >+ * <li>If URL rewriting hasn't been disabled for this context > * </ul> > * > * @param location Absolute URL to be validated > */ > protected boolean isEncodeable(final String location) { >- >+ if (getContext().isDisableURLRewriting()) >+ return (false); > if (location == null) > return (false); > >Index: java/org/apache/catalina/core/StandardContext.java >=================================================================== >--- java/org/apache/catalina/core/StandardContext.java (revision 1005191) >+++ java/org/apache/catalina/core/StandardContext.java (working copy) >@@ -341,6 +341,12 @@ > > > /** >+ * Has URL rewriting been disabled. >+ */ >+ private boolean disableURLRewriting = false; >+ >+ >+ /** > * The exception pages for this web application, keyed by fully qualified > * class name of the Java exception. > */ >@@ -1461,6 +1467,37 @@ > this.docBase = docBase; > > } >+ >+ /** >+ * Is URL rewriting disabled? >+ * URL rewriting is an optional component of the servlet 2.5 specification. >+ * However if set to true this will be non-compliant with the specification >+ * as the specification requires that there <b>must</b> be a way to retain >+ * sessions if the client doesn't allow session cookies. >+ * >+ * @return true If URL rewriting is disabled. >+ * >+ * @see <a href="http://jcp.org/aboutJava/communityprocess/mrel/jsr154/index2.html">Servlet >+ * 2.5 Specification. Sections SRV.7.1.3 and SRV.7.1.4</a> >+ * @see javax.servlet.http.HttpServletResponse#encodeURL(String) encodeURL >+ * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(String) >+ * encodeRedirectURL >+ */ >+ public boolean isDisableURLRewriting() { >+ return (this.disableURLRewriting); >+ } >+ >+ /** >+ * Sets the disabling of URL Rewriting. >+ * @param disable True to disable URL Rewriting. Default <b>false</b>. >+ */ >+ public void setDisableURLRewriting(boolean disable){ >+ boolean oldDisableURLRewriting = this.isDisableURLRewriting(); >+ this.disableURLRewriting = disable; >+ support.firePropertyChange("disableURLRewriting", >+ oldDisableURLRewriting, disableURLRewriting); >+ >+ } > > // experimental > public boolean isLazy() { >Index: java/org/apache/catalina/core/mbeans-descriptors.xml >=================================================================== >--- java/org/apache/catalina/core/mbeans-descriptors.xml (revision 1005191) >+++ java/org/apache/catalina/core/mbeans-descriptors.xml (working copy) >@@ -135,6 +135,11 @@ > description="String deployment descriptor " > type="java.lang.String"/> > >+ <attribute name="disableURLRewriting" >+ description="Is URL Rewriting disabled?" >+ is="true" >+ type="boolean"/> >+ > <attribute name="docBase" > description="The document root for this web application" > type="java.lang.String"/>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 49811
:
25930
|
25961
|
26018
| 26135