Kaynağa Gözat

replace deprecated

andre 9 ay önce
ebeveyn
işleme
c606cc8894
1 değiştirilmiş dosya ile 10 ekleme ve 11 silme
  1. 10 11
      idna_convert.class.php

+ 10 - 11
idna_convert.class.php

@@ -368,7 +368,7 @@ class idna_convert {
         $delim_pos = strrpos($encoded, '-');
         if ($delim_pos > strlen($this->_punycode_prefix)) {
             for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
-                $decoded[] = ord($encoded{$k});
+                $decoded[] = ord($encoded[$k]);
             }
         } else {
             $decoded = array();
@@ -382,7 +382,7 @@ class idna_convert {
         $char = $this->_initial_n;
         for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
             for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) {
-                $digit = $this->_decode_digit($encoded{$enco_idx++});
+                $digit = $this->_decode_digit($encoded[$enco_idx++]);
                 $idx += $digit * $w;
                 $t = ($k <= $bias) ? $this->_tmin :
                         (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
@@ -777,7 +777,7 @@ class idna_convert {
         $mode = 'next';
         $test = 'none';
         for ($k = 0; $k < $inp_len; ++$k) {
-            $v = ord($input{$k}); // Extract byte from input string
+            $v = ord($input[$k]); // Extract byte from input string
             if ($v < 128) { // We found an ASCII char - put into stirng as is
                 $output[$out_len] = $v;
                 ++$out_len;
@@ -913,7 +913,7 @@ class idna_convert {
                 $out_len++;
                 $output[$out_len] = 0;
             }
-            $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
+            $output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4) ) );
         }
         return $output;
     }
@@ -1059,11 +1059,11 @@ class owncloud_Encoding {
 
             $buf = "";
             for ($i = 0; $i < $max; $i++) {
-                $c1 = $text{$i};
+                $c1 = $text[$i];
                 if ($c1 >= "\xc0") { //Should be converted to UTF8, if it's not UTF8 already
-                    $c2 = $i + 1 >= $max ? "\x00" : $text{$i + 1};
-                    $c3 = $i + 2 >= $max ? "\x00" : $text{$i + 2};
-                    $c4 = $i + 3 >= $max ? "\x00" : $text{$i + 3};
+                    $c2 = $i + 1 >= $max ? "\x00" : $text[$i + 1];
+                    $c3 = $i + 2 >= $max ? "\x00" : $text[$i + 2];
+                    $c4 = $i + 3 >= $max ? "\x00" : $text[$i + 3];
                     if ($c1 >= "\xc0" & $c1 <= "\xdf") { //looks like 2 bytes UTF8
                         if ($c2 >= "\x80" && $c2 <= "\xbf") { //yeah, almost sure it's UTF8 already
                             $buf .= $c1 . $c2;
@@ -1199,9 +1199,8 @@ class owncloud_Encoding {
 
     protected static function utf8_decode($text, $option) {
         if ($option == self::WITHOUT_ICONV || !function_exists('iconv')) {
-            $o = utf8_decode(
-                    str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text))
-            );
+            $o = mb_convert_encoding(
+                    str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text)), 'ISO-8859-1', 'UTF-8');
         } else {
             $o = iconv("UTF-8", "Windows-1252" . ($option == self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option == self::ICONV_IGNORE ? '//IGNORE' : '')), $text);
         }