From 39f8e2045e2de21e97dc20dbaded71d4ceeb82bc Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Tue, 2 Dec 2008 23:45:41 +0000 Subject: [PATCH] (NewNamespaceScriptUrl): Try and handle the case of namespaces containing non-ASCII characters. This should be legal, but lead to problems when generating links to pages in such namespaces. The URL encoding of the non-ASCII characters prevented the $InterSitePattern from matching. Instead of using this regular expression, we now try and guess at the string using URL constraints ([^/?&;=]+), URL decoding it, and then checking the $InterSitePattern. --- modules/namespaces.pl | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/namespaces.pl b/modules/namespaces.pl index c179ddc4..db9c40b5 100644 --- a/modules/namespaces.pl +++ b/modules/namespaces.pl @@ -36,7 +36,7 @@ be changed using the C<$NamespacesSelf> option. =cut -$ModulesDescription .= '

$Id: namespaces.pl,v 1.40 2008/09/22 01:31:38 as Exp $

'; +$ModulesDescription .= '

$Id: namespaces.pl,v 1.41 2008/12/02 23:45:41 as Exp $

'; use vars qw($NamespacesMain $NamespacesSelf $NamespaceCurrent $NamespaceRoot $NamespaceSlashing); @@ -253,18 +253,26 @@ sub NewNamespaceScriptUrl { my ($action, @rest) = @_; local $ScriptName = $ScriptName; if ($action =~ /^($UrlProtocols)\%3a/) { # URL-encoded URL - # do nothing - } elsif ($action =~ /(.*?)\b($InterSitePattern)%3a(.*)/) { - if ("$2:$3" eq GetParam('oldid', '')) { - if ($2 eq $NamespacesMain) { - $ScriptName = $NamespaceRoot; + # do nothing (why do we need this?) + } elsif ($action =~ m!(.*?)([^/?&;=]+)%3a(.*)!) { + # $2 is supposed to match the $InterSitePattern, but it might be + # UrlEncoded in Main:RecentChanges. If $2 contains Umlauts, for + # example, the encoded $2 will no longer match $InterSitePattern. + # We have a likely candidate -- now perform an additional test. + my ($s1, $s2, $s3) = ($1, $2, $3); + my $s = UrlDecode($s2); + if ($s =~ /^$InterSitePattern$/) { + if ("$s2:$s3" eq GetParam('oldid', '')) { + if ($s2 eq $NamespacesMain) { + $ScriptName = $NamespaceRoot; + } else { + $ScriptName = $NamespaceRoot . '/' . $s2; + } } else { - $ScriptName = $NamespaceRoot . '/' . $2; + $ScriptName .= '/' . $s2; } - } else { - $ScriptName .= '/' . $2; + $action = $s1 . $s3; } - $action = $1 . $3; } return OldNamespaceScriptUrl($action, @rest); }