Details
-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
5.1
-
None
-
Unknown
-
N/A
-
N/A
-
Description
The urlrewritefilter library (http://www.tuckey.org/urlrewrite/) is a great tool for implementing short urls (as described on http://platform.xwiki.org/xwiki/bin/view/Main/ShortURLs). It supports both inbound URL rewriting and outbound rewriting. However in order for the outbound rule to work we need to call Response.encodeURL(), see http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpServletResponse.html#encodeURL(java.lang.String)
I've tested it and it works if I modify XWikiServletURLFactory.createURL() by adding:
URL result; try { result = new URL(getServerURL(xwikidb, context), newpath.toString()); // For robust session tracking, all URLs emitted by a servlet should be encoded. Otherwise, URL rewriting // cannot be used with browsers which do not support cookies. String encodedURLAsString = context.getResponse().encodeURL(result.toExternalForm()); result = new URL(encodedURLAsString); } catch (MalformedURLException e) { // This should not happen result = null; }
I hate the fact that we construct a URL, then serialize it to a String and then again reconstruct a URL but I don't see any way out of this.
WDYT?
Attachments
Issue Links
- duplicates
-
XWIKI-9437 Fully allow using XWiki when cookies are turned off
- Closed
- relates to
-
XWIKI-1181 Outbound rewrite rules
- Closed