Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1
    • Fix Version/s: None
    • Component/s: Old Core
    • Labels:
      None
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      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

            Activity

              People

              • Assignee:
                vmassol Vincent Massol
                Reporter:
                vmassol Vincent Massol
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: