Prechádzať zdrojové kódy

fix issue where /secure/secure/secure local_hrefs propagated

George Baugh 4 mesiacov pred
rodič
commit
ee441c0ad6
2 zmenil súbory, kde vykonal 10 pridanie a 2 odobranie
  1. 5 2
      lib/TCMS.pm
  2. 5 0
      lib/Trog/DataModule.pm

+ 5 - 2
lib/TCMS.pm

@@ -167,8 +167,11 @@ sub _routes ( $data = {} ) {
     # XXX this is probably bad in the case of the specific content-typed routes, they should be mutex
     my %roots = $data->routes();
 
-    # Setup the /secure/... versions for logged in users
-    @roots{ map { "/secure$_" } keys(%roots) } = values(%roots);
+    # Setup the /secure/... versions for logged in users, except for already secured routes.
+    foreach my $route (keys(%roots)) {
+        next if index($route, '/secure/') == 0;
+        $roots{"/secure$route"} = $roots{$route};
+    }
 
     # It is the responsibility of theme authors to setup /secure routes (other than index)
     my %themed = Trog::Themes::routes();

+ 5 - 0
lib/Trog/DataModule.pm

@@ -402,6 +402,11 @@ sub add ( $self, @posts ) {
         }
         $post->{version} //= 0;
 
+        #XXX if local_href has /secure paths in it, fix this.  We don't want to save that.
+        if (index($post->{local_href}, '/secure/') == 0) {
+            $post->{local_href} =~ s|/secure||gmx;
+        }
+
         $post = _process($post);
 
         push @to_write, $post;