From 71dbfcf4b70ea77812d331415eab920d3389ea8d Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Mon, 2 Apr 2007 17:05:39 +0000 Subject: [PATCH] ($NamespaceSlashing): New variable. (NewNamespaceDoRc): Set it. (NewNamespaceUrlEncode): Wrapper around UrlEncode() that uses it. --- modules/namespaces.pl | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/modules/namespaces.pl b/modules/namespaces.pl index bcceca8e..7411faa0 100644 --- a/modules/namespaces.pl +++ b/modules/namespaces.pl @@ -16,15 +16,17 @@ # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA -$ModulesDescription .= '

$Id: namespaces.pl,v 1.29 2006/12/22 15:27:17 as Exp $

'; +$ModulesDescription .= '

$Id: namespaces.pl,v 1.30 2007/04/02 17:05:39 as Exp $

'; -use vars qw($NamespacesMain $NamespacesSelf $NamespaceCurrent $NamespaceRoot); +use vars qw($NamespacesMain $NamespacesSelf $NamespaceCurrent $NamespaceRoot $NamespaceSlashing); $NamespacesMain = 'Main'; # to get back to the main namespace $NamespacesSelf = 'Self'; # for your own namespace $NamespaceCurrent = ''; # will be automatically set to the current namespace, if any $NamespaceRoot = ''; # will be automatically set to the original $ScriptName +$NamespaceSlashing = 0; # When set, UrlEncode will immediately decode the / added by NamespaceRcLines + # try to do it before any other module starts meddling with the # variables (eg. localnames.pl) unshift(@MyInitVariables, \&NamespacesInitVariables); @@ -36,8 +38,8 @@ sub NamespacesInitVariables { $site{$NamespacesMain} = $ScriptName . '/'; foreach my $name (glob("$DataDir/*")) { if (-d $name - and $name =~ m|/($InterSitePattern)$| - and $name ne $NamespacesMain + and $name =~ m|/($InterSitePattern)$| + and $name ne $NamespacesMain and $name ne $NamespacesSelf) { $site{$1} = $ScriptName . '/' . $1 . '/'; } @@ -68,7 +70,7 @@ sub NamespacesInitVariables { $TempDir = "$DataDir/temp"; $LockDir = "$TempDir/lock"; $NoEditFile = "$DataDir/noedit"; - $RcFile = "$DataDir/rc.log"; + $RcFile = "$DataDir/rc.log"; $RcOldFile = "$DataDir/oldrc.log"; $IndexFile = "$DataDir/pageidx"; $VisitorFile = "$DataDir/visitors.log"; @@ -159,6 +161,7 @@ sub NewNamespaceDoRc { # Copy of DoRc @lines = sort { $a <=> $b } @lines; # end, printing local *ValidId = *NamespaceValidId; + local $NamespaceSlashing = 1; if (not @lines and $showHTML) { print $q->p($q->strong(Ts('No updates since %s', TimeToText($starttime)))); } else { @@ -204,6 +207,15 @@ sub NamespaceRcLines { return ($first, @result); } +*OldNamespaceUrlEncode = *UrlEncode; +*UrlEncode = *NewNamespaceUrlEncode; + +sub NewNamespaceUrlEncode { + my $result = OldNamespaceUrlEncode(@_); + $result =~ s/\%2f/\// if $NamespaceSlashing; # just one should be enough + return $result; +} + *OldNamespaceScriptLink = *ScriptLink; *ScriptLink = *NewNamespaceScriptLink;