X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=languages%2FLanguage.php;h=320cdf2622c16fb231fac741528bc7d1f63c957a;hb=5691476a3d87f7368fc09cc967a981cf29b863ad;hp=b026fad8a234b22f0b268563eced4884aff9210e;hpb=458f106e32d4af8455e20af9a8d69b5dfe89f9b5;p=lhc%2Fweb%2Fwiklou.git diff --git a/languages/Language.php b/languages/Language.php index b026fad8a2..320cdf2622 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -246,7 +246,11 @@ class Language { */ public static function isValidCode( $code ) { return - strcspn( $code, ":/\\\000" ) === strlen( $code ) + // People think language codes are html safe, so enforce it. + // Ideally we should only allow a-zA-Z0-9- + // but, .+ and other chars are often used for {{int:}} hacks + // see bugs 37564, 37587, 36938 + strcspn( $code, ":/\\\000&<>'\"" ) === strlen( $code ) && !preg_match( Title::getTitleInvalidRegex(), $code ); } @@ -1268,7 +1272,7 @@ class Language { $s .= $num; $raw = false; } elseif ( $roman ) { - $s .= self::romanNumeral( $num ); + $s .= Language::romanNumeral( $num ); $roman = false; } elseif ( $hebrewNum ) { $s .= self::hebrewNumeral( $num ); @@ -1657,7 +1661,7 @@ class Language { } /** - * Roman number formatting up to 3000 + * Roman number formatting up to 10000 * * @param $num int * @@ -1668,11 +1672,11 @@ class Language { array( '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X' ), array( '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', 'C' ), array( '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', 'M' ), - array( '', 'M', 'MM', 'MMM' ) + array( '', 'M', 'MM', 'MMM', 'MMMM', 'MMMMM', 'MMMMMM', 'MMMMMMM', 'MMMMMMMM', 'MMMMMMMMM', 'MMMMMMMMMM' ) ); $num = intval( $num ); - if ( $num > 3000 || $num <= 0 ) { + if ( $num > 10000 || $num <= 0 ) { return $num; } @@ -1758,7 +1762,7 @@ class Language { * @return int */ function userAdjust( $ts, $tz = false ) { - global $wgUser, $wgLocaltimezone, $wgLocalTZoffset; + global $wgUser, $wgLocalTZoffset; if ( $tz === false ) { $tz = $wgUser->getOption( 'timecorrection' ); @@ -1766,18 +1770,6 @@ class Language { $data = explode( '|', $tz, 3 ); - if ( $data[0] == 'System' || $tz == '' ) { - # Global timezone - if ( isset( $wgLocaltimezone ) ) { - $data[0] = 'ZoneInfo'; - $data[2] = $wgLocaltimezone; - } - #  Global offset in minutes. - if ( isset( $wgLocalTZoffset ) ) { - $data[1] = $wgLocalTZoffset; - } - } - if ( $data[0] == 'ZoneInfo' ) { wfSuppressWarnings(); $userTZ = timezone_open( $data[2] ); @@ -1793,7 +1785,12 @@ class Language { } $minDiff = 0; - if ( $data[0] == 'Offset' ) { + if ( $data[0] == 'System' || $tz == '' ) { + #  Global offset in minutes. + if ( isset( $wgLocalTZoffset ) ) { + $minDiff = $wgLocalTZoffset; + } + } elseif ( $data[0] == 'Offset' ) { $minDiff = intval( $data[1] ); } else { $data = explode( ':', $tz ); @@ -2709,6 +2706,7 @@ class Language { * * @param $opposite Boolean Get the direction mark opposite to your language * @return string + * @since 1.20 */ function getDirMarkEntity( $opposite = false ) { if ( $opposite ) { return $this->isRTL() ? '‎' : '‏'; } @@ -2999,6 +2997,7 @@ class Language { * Take a list of strings and build a locale-friendly comma-separated * list, using the local comma-separator message. * The last two strings are chained with an "and". + * NOTE: This function will only work with standard numeric array keys (0, 1, 2…) * * @param $l Array * @return string @@ -3006,7 +3005,10 @@ class Language { function listToText( array $l ) { $s = ''; $m = count( $l ) - 1; - if ( $m == 1 ) { + + if ( $m === 0 ) { + return $l[0]; + } elseif ( $m === 1 ) { return $l[0] . $this->getMessageFromDB( 'and' ) . $this->getMessageFromDB( 'word-separator' ) . $l[1]; } else { for ( $i = $m; $i >= 0; $i-- ) { @@ -3914,12 +3916,13 @@ class Language { /** * Decode an expiry (block, protection, etc) which has come from the DB * - * @FIXME: why are we returnings DBMS-dependent strings??? + * @todo FIXME: why are we returnings DBMS-dependent strings??? * * @param $expiry String: Database expiry String * @param $format Bool|Int true to process using language functions, or TS_ constant * to return the expiry in a given timestamp * @return String + * @since 1.18 */ public function formatExpiry( $expiry, $format = true ) { static $infinity, $infinityMsg;