Item8186: Infinite redirect loop when using Jump box and short urls

Priority: Low
Current State: New
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: RedirectPlugin
Reported By: Foswiki:Main.JeffVStein
Waiting For:
Last Change By: BenjaminMartin


When using short urls, it's very easy to get into an infinite loop by putting a redirected topic into the Jump box at the top. This results in the following error in Firefox:

Redirect Loop

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.

    * Have you disabled or blocked cookies required by this site?
    * NOTE: If accepting the site's cookies does not resolve the problem, it is likely a server configuration issue and not your computer.     


The Jump box is a basic HTML form that goes against the current page, using the user input as the topic value. This gives you a request string like:

RedirectPlugin then looks up the destination url using Foswiki::Func::getViewUrl and then appends the query string to this value.

The topic value at the end of the URL overrides the internal value and you get a redirect loop because RedirectPlugin keeps passing the topic variable.


As mentioned on the TWiki site for RedirectPlugin, you can modify the /path/to/Foswiki/lib/Foswiki/Plugins/ to omit the topic parameter.

Since RedirectPlugin uses the internal Foswiki::Func::getViewUrl call, it shouldn't need to append the topic variable and it can probably always be omitted.

 my $queryString = "";
 my $param;
 foreach my $param ( $query->param ) {
+    $param eq 'topic' and next;
     $queryString .= "&" if $queryString;
     $queryString .= "$param=" . $query->param("$param");

-- JeffVStein - 22 Jun 2009

Using Foswiki 1.1.9, I just added some lines to /path/to/Foswiki/lib/Foswiki/Plugins/ to prevent infinits loops.
   my $queryString = "";
   my $param;
+  my $oldvalue = "";
        foreach my $param ( $query->param ) {
            foreach my $value ( $query->param("$param") ) {
+              $oldvalue = "$param=" . $value;
+              last if $queryString =~ m{.*$oldvalue.*};
               $queryString .= "&" if $queryString;
               $queryString .= "$param=" . $value;
NOTE: could be optimized

After some hours this did not work anymore (why?). So I removed all those "foreach"-loops and the final $q variable. Result: jumps on redirect are fast and without errors, but lack the information of "?redirectedfrom=...".

-- BenjaminMartin - 03 Mar 2015

ItemTemplate edit

Summary Infinite redirect loop when using Jump box and short urls
ReportedBy Foswiki:Main.JeffVStein
Codebase 1.0.5, trunk
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component RedirectPlugin
Priority Low
CurrentState New
TargetRelease n/a
ReleasedIn n/a
Topic revision: r5 - 04 Mar 2015, BenjaminMartin - This page was cached on 05 Jun 2020 - 19:14.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy