diff --git a/Application/Base/Service/GameSourceService.class.php b/Application/Base/Service/GameSourceService.class.php index 0c4ff1eb0..3ba19c298 100644 --- a/Application/Base/Service/GameSourceService.class.php +++ b/Application/Base/Service/GameSourceService.class.php @@ -57,7 +57,7 @@ class GameSourceService { public function getChannelConfigFolder($zip, array $packData) { $appPath = $this->getIpaAppPath($zip); - return $appPath . '/TXChannel/' . Base62::encode(json_encode($packData)); + return $appPath . '/TXChannel/' . Base62::encode(json_encode($packData, JSON_UNESCAPED_UNICODE)); } public function getGameSourceUrl($gameSource) diff --git a/Application/Base/Tool/Base62.class.php b/Application/Base/Tool/Base62.class.php index b7eba121e..35d047767 100644 --- a/Application/Base/Tool/Base62.class.php +++ b/Application/Base/Tool/Base62.class.php @@ -27,11 +27,18 @@ class Base62 return $chars; } + public static function getSpecialChar($char, $default = null) + { + if ($default == null) { + $default = $char; + } + return $char == 'i' ? "ia" : ($char == '+' ? "ib" : ($char == '/' ? "ic" : $default)); + } + public static function encode($string) { $encodes = self::getCharArray(self::ENCODES); $bytes = self::stringToBytes($string); - $pos = 0; $val = 0; $result = []; @@ -40,21 +47,14 @@ class Base62 $pos += 8; while ($pos > 5) { $char = $encodes[$val >> ($pos -= 6)]; - $result[] = ( - $char == 'i' ? "ia" : - $char == '+' ? "ib" : - $char == '/' ? "ic" : $char - ); + $encodeChar = self::getSpecialChar($char); + $result[] = $encodeChar; $val &= ((1 << $pos) - 1); } } if ($pos > 0) { $char = $encodes[$val << (6 - $pos)]; - $result[] = ( - $char == 'i' ? "ia" : - $char == '+' ? "ib" : - $char == '/' ? "ic" : $char - ); + $result[] = self::getSpecialChar($char); } return implode('', $result); } @@ -70,10 +70,10 @@ class Base62 $char = $chars[$i]; if ($char == 'i') { $char = $chars[++$i]; - $char = + $char = $char == 'a' ? 'i' : - $char == 'b' ? '+' : - $char == 'c' ? '/' : $chars[--$i]; + ($char == 'b' ? '+' : + ($char == 'c' ? '/' : $chars[--$i])); } $val = ($val << 6) | $decodes[$char]; $pos += 6;