[Rt-commit] rt branch, 4.0/canonicalize-multiple-slashes, created. rt-4.0.5-118-g9b8d142

Thomas Sibley trs at bestpractical.com
Mon Aug 27 19:57:58 EDT 2012


The branch, 4.0/canonicalize-multiple-slashes has been created
        at  9b8d1425f8f9905e2a2cacf7e544e6fbb0efa74d (commit)

- Log -----------------------------------------------------------------
commit 3692e2bc9601bbb23d78ef7ec32c517be8f22740
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Apr 12 23:45:48 2012 +0800

    canonicalize away multiple slashes
    
    as we match the request path by m{^/...} in the following code,
    this canonizalization helps when user uses interesting urls
    like //Ticket/Display.html
    
    see #19723

diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index f65f909..2442ce6 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -50,6 +50,7 @@
 <%INIT>
 
 my $request_path = $HTML::Mason::Commands::r->path_info;
+$request_path =~ s!/{2,}!/!g;
 
 my $query_string = sub {
     my %args = @_;

commit 9b8d1425f8f9905e2a2cacf7e544e6fbb0efa74d
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Aug 27 16:48:20 2012 -0700

    Squash multiple consecutive slashes into single slashes in menu paths
    
    The previous regex targeted a single failure case where the path is /
    and the parent's path is / and then we tacked on a trailing /.
    
    A more common case is the parent's path already containing a trailing
    slash, leading to a double slash which wasn't canonicalized away.

diff --git a/lib/RT/Interface/Web/Menu.pm b/lib/RT/Interface/Web/Menu.pm
index 6b351e9..ba601fd 100644
--- a/lib/RT/Interface/Web/Menu.pm
+++ b/lib/RT/Interface/Web/Menu.pm
@@ -153,7 +153,7 @@ sub path {
         $self->{path} = shift;
         $self->{path} = URI->new_abs($self->{path}, $self->parent->path . "/")->as_string
             if defined $self->{path} and $self->parent and $self->parent->path;
-        $self->{path} =~ s!///!/! if $self->{path};
+        $self->{path} =~ s!/+!/!g if $self->{path};
     }
     return $self->{path};
 }

-----------------------------------------------------------------------


More information about the Rt-commit mailing list