From 697a9948df3c9d4275b3525227007bfd5a1c5709 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 27 May 2010 14:18:08 -0700 Subject: Ticket #2329: fix for use of _m() translation functions from outside of plugin directories --- lib/language.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/language.php b/lib/language.php index 64b59e739..3846b8f35 100644 --- a/lib/language.php +++ b/lib/language.php @@ -205,12 +205,20 @@ function _mdomain($backtrace) if (DIRECTORY_SEPARATOR !== '/') { $path = strtr($path, DIRECTORY_SEPARATOR, '/'); } - $cut = strpos($path, '/plugins/') + 9; - $cut2 = strpos($path, '/', $cut); - if ($cut && $cut2) { - $cached[$path] = substr($path, $cut, $cut2 - $cut); - } else { + $plug = strpos($path, '/plugins/'); + if ($plug === false) { + // We're not in a plugin; return null for the default domain. return null; + } else { + $cut = $plug + 9; + $cut2 = strpos($path, '/', $cut); + if ($cut2) { + $cached[$path] = substr($path, $cut, $cut2 - $cut); + } else { + // We might be running directly from the plugins dir? + // If so, there's no place to store locale info. + return null; + } } } return $cached[$path]; -- cgit v1.2.3