use IdnaConvert from composer
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -40,7 +40,8 @@
|
||||
"ext-mbstring" : "*",
|
||||
"ext-curl" : "*",
|
||||
"ext-json" : "*",
|
||||
"ext-openssl": "*"
|
||||
"ext-openssl": "*",
|
||||
"mso/idna-convert" : "1.*"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit" : "6.5.13",
|
||||
|
||||
@@ -203,8 +203,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
|
||||
// validation
|
||||
$name = validate($name, 'name', '', '', array(), true);
|
||||
// @fixme idna_convert_wrapper
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$email = $idna_convert->encode(validate($email, 'email', '', '', array(), true));
|
||||
$def_language = validate($def_language, 'default language', '', '', array(), true);
|
||||
$custom_notes = validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true);
|
||||
@@ -461,8 +460,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
if ($this->getUserDetail('change_serversettings') == 1 || $result['adminid'] == $this->getUserDetail('adminid')) {
|
||||
// parameters
|
||||
$name = $this->getParam('name', true, $result['name']);
|
||||
// @fixme idna_convert_wrapper
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$email = $this->getParam('email', true, $idna_convert->decode($result['email']));
|
||||
$password = $this->getParam('admin_password', true, '');
|
||||
$def_language = $this->getParam('def_language', true, $result['def_language']);
|
||||
@@ -521,8 +519,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
|
||||
// validation
|
||||
$name = validate($name, 'name', '', '', array(), true);
|
||||
// @fixme idna_convert_wrapper
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$email = $idna_convert->encode(validate($email, 'email', '', '', array(), true));
|
||||
$def_language = validate($def_language, 'default language', '', '', array(), true);
|
||||
$custom_notes = validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace Froxlor\Api\Commands;
|
||||
|
||||
use Froxlor\Database as Database;
|
||||
use Froxlor\Settings as Settings;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
|
||||
@@ -267,8 +267,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
$city = validate($city, 'city', '', '', array(), true);
|
||||
$phone = validate($phone, 'phone', '/^[0-9\- \+\(\)\/]*$/', '', array(), true);
|
||||
$fax = validate($fax, 'fax', '/^[0-9\- \+\(\)\/]*$/', '', array(), true);
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$email = $idna_convert->encode(validate($email, 'email', '', '', array(), true));
|
||||
$customernumber = validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true);
|
||||
$def_language = validate($def_language, 'default language', '', '', array(), true);
|
||||
@@ -868,8 +867,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
// parameters
|
||||
$move_to_admin = intval_ressource($this->getBoolParam('move_to_admin', true, 0));
|
||||
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$email = $this->getParam('email', true, $idna_convert->decode($result['email']));
|
||||
$name = $this->getParam('name', true, $result['name']);
|
||||
$firstname = $this->getParam('firstname', true, $result['firstname']);
|
||||
@@ -917,8 +915,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
|
||||
// validation
|
||||
if ($this->isAdmin()) {
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$name = validate($name, 'name', '', '', array(), true);
|
||||
$firstname = validate($firstname, 'first name', '', '', array(), true);
|
||||
$company = validate($company, 'company', '', '', array(), true);
|
||||
@@ -1093,8 +1090,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
Database::needRoot(true);
|
||||
$last_dbserver = 0;
|
||||
|
||||
// @fixme dbManager
|
||||
$dbm = new \DbManager($this->logger());
|
||||
$dbm = new \Froxlor\Database\DbManager($this->logger());
|
||||
|
||||
// For each of them
|
||||
while ($row_database = $databases_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
@@ -1402,7 +1398,6 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
));
|
||||
$id = $result['customerid'];
|
||||
|
||||
// @fixme use Databases-ApiCommand later
|
||||
$databases_stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_DATABASES . "`
|
||||
WHERE `customerid` = :id ORDER BY `dbserver`
|
||||
@@ -1413,8 +1408,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
||||
Database::needRoot(true);
|
||||
$last_dbserver = 0;
|
||||
|
||||
// @fixme db manager
|
||||
$dbm = new \DbManager($this->logger());
|
||||
$dbm = new \Froxlor\Database\DbManager($this->logger());
|
||||
|
||||
while ($row_database = $databases_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if ($last_dbserver != $row_database['dbserver']) {
|
||||
|
||||
@@ -76,8 +76,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
||||
standard_error('dns_domain_nodns', '', true);
|
||||
}
|
||||
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$domain = $idna_convert->encode($result['domain']);
|
||||
|
||||
// select all entries
|
||||
|
||||
@@ -82,8 +82,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
|
||||
// convert possible idn domain to punycode
|
||||
if (substr($domainname, 0, 4) != 'xn--') {
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$domainname = $idna_convert->encode($domainname);
|
||||
}
|
||||
|
||||
@@ -240,8 +239,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
standard_error('domain_nopunycode', '', true);
|
||||
}
|
||||
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$domain = $idna_convert->encode(preg_replace(array(
|
||||
'/\:(\d)+$/',
|
||||
'/^https?\:\/\//'
|
||||
@@ -504,8 +502,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
||||
$issubof = '0';
|
||||
}
|
||||
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
if ($domain == '') {
|
||||
standard_error(array(
|
||||
'stringisempty',
|
||||
|
||||
@@ -82,8 +82,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
|
||||
$id = $result['id'];
|
||||
|
||||
$email_full = $result['email_full'];
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$username = $idna_convert->decode($email_full);
|
||||
$password = validate($email_password, 'password', '', '', array(), true);
|
||||
$password = validatePassword($password, true);
|
||||
|
||||
@@ -54,8 +54,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
|
||||
$destination = $this->getParam('destination');
|
||||
|
||||
// validation
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$destination = $idna_convert->encode($destination);
|
||||
|
||||
$result = $this->apiCall('Emails.get', array(
|
||||
|
||||
@@ -57,8 +57,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
|
||||
// validation
|
||||
if (substr($domain, 0, 4) != 'xn--') {
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$domain = $idna_convert->encode(validate($domain, 'domain', '', '', array(), true));
|
||||
}
|
||||
|
||||
|
||||
@@ -80,8 +80,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
if (Settings::Get('customer.ftpatdomain') == '1') {
|
||||
$ftpusername = validate(trim($ftpusername), 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/', '', array(), true);
|
||||
if (substr($ftpdomain, 0, 4) != 'xn--') {
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$ftpdomain = $idna_convert->encode(validate($ftpdomain, 'domain', '', '', array(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +79,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
'mysql_lastaccountnumber' => ($this->isAdmin() ? $customer['mysql_lastaccountnumber'] : $this->getUserDetail('mysql_lastaccountnumber'))
|
||||
);
|
||||
// create database, user, set permissions, etc.pp.
|
||||
// @fixme dbManager
|
||||
$dbm = new \DbManager($this->logger());
|
||||
$dbm = new \Froxlor\Database\DbManager($this->logger());
|
||||
$username = $dbm->createDatabase($newdb_params['loginname'], $password, $newdb_params['mysql_lastaccountnumber']);
|
||||
|
||||
// we've checked against the password in dbm->createDatabase
|
||||
@@ -459,8 +458,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
||||
|
||||
// Begin root-session
|
||||
Database::needRoot(true, $result['dbserver']);
|
||||
// @fixme dbManager
|
||||
$dbm = new \DbManager($this->logger());
|
||||
$dbm = new \Froxlor\Database\DbManager($this->logger());
|
||||
$dbm->getManager()->deleteDatabase($result['databasename']);
|
||||
Database::needRoot(false);
|
||||
// End root-session
|
||||
|
||||
@@ -94,8 +94,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
standard_error('domain_nopunycode', '', true);
|
||||
}
|
||||
|
||||
// @fixme idna_convert_wrapper
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$subdomain = $idna_convert->encode(preg_replace(array(
|
||||
'/\:(\d)+$/',
|
||||
'/^https?\:\/\//'
|
||||
@@ -342,8 +341,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
|
||||
// convert possible idn domain to punycode
|
||||
if (substr($domainname, 0, 4) != 'xn--') {
|
||||
// @fixme idna_convert_wrapper
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$domainname = $idna_convert->encode($domainname);
|
||||
}
|
||||
|
||||
@@ -581,8 +579,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
Database::pexecute($stmt, $params, true, true);
|
||||
$stmt = Database::prepare("DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid`= :customerid AND `domainid`= :domainid");
|
||||
Database::pexecute($stmt, $params, true, true);
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_NOTICE, "[API] automatically deleted mail-table entries for '" . $idna_convert->decode($result['domain']) . "'");
|
||||
}
|
||||
|
||||
@@ -647,8 +644,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
||||
|
||||
inserttask('1');
|
||||
inserttask('4');
|
||||
// @fixme idna
|
||||
$idna_convert = new \idna_convert_wrapper();
|
||||
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] edited domain '" . $idna_convert->decode($result['domain']) . "'");
|
||||
}
|
||||
$result = $this->apiCall('SubDomains.get', array(
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
namespace Froxlor\Database;
|
||||
|
||||
use \Froxlor\Settings;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
@@ -47,7 +50,7 @@ class DbManager {
|
||||
/**
|
||||
* main constructor
|
||||
*
|
||||
* @param FroxlorLogger $log
|
||||
* @param \FroxlorLogger $log
|
||||
*/
|
||||
public function __construct($log = null) {
|
||||
$this->_log = $log;
|
||||
@@ -122,6 +125,6 @@ class DbManager {
|
||||
*/
|
||||
private function _setManager() {
|
||||
// TODO read different dbms from settings later
|
||||
$this->_manager = new DbManagerMySQL($this->_log);
|
||||
$this->_manager = new \Froxlor\Database\Manager\DbManagerMySQL($this->_log);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
namespace Froxlor\Database\Manager;
|
||||
|
||||
use Froxlor\Database;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
@@ -8,14 +11,14 @@
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Michael Kaufmann <mkaufmann@nutime.de>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Classes
|
||||
*
|
||||
* @since 0.9.31
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Michael Kaufmann <mkaufmann@nutime.de>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Classes
|
||||
*
|
||||
* @since 0.9.31
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -24,16 +27,18 @@
|
||||
* Explicit class for database-management like creating
|
||||
* and removing databases, users and permissions for MySQL
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Michael Kaufmann <mkaufmann@nutime.de>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Classes
|
||||
* @copyright (c) the authors
|
||||
* @author Michael Kaufmann <mkaufmann@nutime.de>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Classes
|
||||
*/
|
||||
class DbManagerMySQL {
|
||||
class DbManagerMySQL
|
||||
{
|
||||
|
||||
/**
|
||||
* FroxlorLogger object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $_log = null;
|
||||
@@ -41,9 +46,10 @@ class DbManagerMySQL {
|
||||
/**
|
||||
* main constructor
|
||||
*
|
||||
* @param FroxlorLogger $log
|
||||
* @param \FroxlorLogger $log
|
||||
*/
|
||||
public function __construct(&$log = null) {
|
||||
public function __construct(&$log = null)
|
||||
{
|
||||
$this->_log = $log;
|
||||
}
|
||||
|
||||
@@ -52,7 +58,8 @@ class DbManagerMySQL {
|
||||
*
|
||||
* @param string $dbname
|
||||
*/
|
||||
public function createDatabase($dbname = null) {
|
||||
public function createDatabase($dbname = null)
|
||||
{
|
||||
Database::query("CREATE DATABASE `" . $dbname . "`");
|
||||
}
|
||||
|
||||
@@ -63,11 +70,13 @@ class DbManagerMySQL {
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $access_host
|
||||
* @param bool $p_encrypted optional, whether the password is encrypted or not, default false
|
||||
* @param bool $p_encrypted
|
||||
* optional, whether the password is encrypted or not, default false
|
||||
*/
|
||||
public function grantPrivilegesTo($username = null, $password = null, $access_host = null, $p_encrypted = false) {
|
||||
public function grantPrivilegesTo($username = null, $password = null, $access_host = null, $p_encrypted = false)
|
||||
{
|
||||
// mysql8 compatibility
|
||||
if (version_compare(Database::getAttribute(PDO::ATTR_SERVER_VERSION), '8.0.11', '>=')) {
|
||||
if (version_compare(Database::getAttribute(\PDO::ATTR_SERVER_VERSION), '8.0.11', '>=')) {
|
||||
// create user
|
||||
$stmt = Database::prepare("
|
||||
CREATE USER '" . $username . "'@'" . $access_host . "' IDENTIFIED BY 'password'
|
||||
@@ -77,16 +86,22 @@ class DbManagerMySQL {
|
||||
$stmt = Database::prepare("
|
||||
GRANT ALL ON `" . $username . "`.* TO :username@:host
|
||||
");
|
||||
Database::pexecute($stmt, array("username" => $username, "host" => $access_host));
|
||||
Database::pexecute($stmt, array(
|
||||
"username" => $username,
|
||||
"host" => $access_host
|
||||
));
|
||||
} else {
|
||||
// grant privileges
|
||||
$stmt = Database::prepare("
|
||||
GRANT ALL PRIVILEGES ON `" . $username . "`.* TO :username@:host IDENTIFIED BY 'password'
|
||||
");
|
||||
Database::pexecute($stmt, array("username" => $username, "host" => $access_host));
|
||||
Database::pexecute($stmt, array(
|
||||
"username" => $username,
|
||||
"host" => $access_host
|
||||
));
|
||||
}
|
||||
// set passoword
|
||||
if (version_compare(Database::getAttribute(PDO::ATTR_SERVER_VERSION), '5.7.6', '<')) {
|
||||
if (version_compare(Database::getAttribute(\PDO::ATTR_SERVER_VERSION), '5.7.6', '<')) {
|
||||
if ($p_encrypted) {
|
||||
$stmt = Database::prepare("SET PASSWORD FOR :username@:host = :password");
|
||||
} else {
|
||||
@@ -95,7 +110,11 @@ class DbManagerMySQL {
|
||||
} else {
|
||||
$stmt = Database::prepare("ALTER USER :username@:host IDENTIFIED BY :password");
|
||||
}
|
||||
Database::pexecute($stmt, array("username" => $username, "host" => $access_host, "password" => $password));
|
||||
Database::pexecute($stmt, array(
|
||||
"username" => $username,
|
||||
"host" => $access_host,
|
||||
"password" => $password
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,26 +123,30 @@ class DbManagerMySQL {
|
||||
*
|
||||
* @param string $dbname
|
||||
*/
|
||||
public function deleteDatabase($dbname = null) {
|
||||
|
||||
if (Database::getAttribute(PDO::ATTR_SERVER_VERSION) < '5.0.2') {
|
||||
public function deleteDatabase($dbname = null)
|
||||
{
|
||||
if (Database::getAttribute(\PDO::ATTR_SERVER_VERSION) < '5.0.2') {
|
||||
// failsafe if user has been deleted manually (requires MySQL 4.1.2+)
|
||||
$stmt = Database::prepare("REVOKE ALL PRIVILEGES, GRANT OPTION FROM `".$dbname."`");
|
||||
$stmt = Database::prepare("REVOKE ALL PRIVILEGES, GRANT OPTION FROM `" . $dbname . "`");
|
||||
Database::pexecute($stmt, array(), false);
|
||||
}
|
||||
|
||||
$host_res_stmt = Database::prepare("
|
||||
SELECT `Host` FROM `mysql`.`user` WHERE `User` = :dbname"
|
||||
);
|
||||
Database::pexecute($host_res_stmt, array('dbname' => $dbname));
|
||||
SELECT `Host` FROM `mysql`.`user` WHERE `User` = :dbname");
|
||||
Database::pexecute($host_res_stmt, array(
|
||||
'dbname' => $dbname
|
||||
));
|
||||
|
||||
while ($host = $host_res_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
while ($host = $host_res_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
// as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+)
|
||||
$drop_stmt = Database::prepare("DROP USER IF EXISTS :dbname@:host");
|
||||
Database::pexecute($drop_stmt, array('dbname' => $dbname, 'host' => $host['Host']), false);
|
||||
Database::pexecute($drop_stmt, array(
|
||||
'dbname' => $dbname,
|
||||
'host' => $host['Host']
|
||||
), false);
|
||||
}
|
||||
|
||||
$drop_stmt = Database::prepare("DROP DATABASE IF EXISTS `".$dbname."`");
|
||||
$drop_stmt = Database::prepare("DROP DATABASE IF EXISTS `" . $dbname . "`");
|
||||
Database::pexecute($drop_stmt);
|
||||
}
|
||||
|
||||
@@ -133,24 +156,30 @@ class DbManagerMySQL {
|
||||
* @param string $username
|
||||
* @param string $host
|
||||
*/
|
||||
public function deleteUser($username = null, $host = null) {
|
||||
if (Database::getAttribute(PDO::ATTR_SERVER_VERSION) < '5.0.2') {
|
||||
public function deleteUser($username = null, $host = null)
|
||||
{
|
||||
if (Database::getAttribute(\PDO::ATTR_SERVER_VERSION) < '5.0.2') {
|
||||
// Revoke privileges (only required for MySQL 4.1.2 - 5.0.1)
|
||||
$stmt = Database::prepare("REVOKE ALL PRIVILEGES ON * . * FROM `". $username . "`@`".$host."`");
|
||||
$stmt = Database::prepare("REVOKE ALL PRIVILEGES ON * . * FROM `" . $username . "`@`" . $host . "`");
|
||||
Database::pexecute($stmt);
|
||||
}
|
||||
// as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+)
|
||||
$stmt = Database::prepare("DROP USER :username@:host");
|
||||
Database::pexecute($stmt, array("username" => $username, "host" => $host));
|
||||
Database::pexecute($stmt, array(
|
||||
"username" => $username,
|
||||
"host" => $host
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* removes permissions from a user
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $host (unused in mysql)
|
||||
* @param string $host
|
||||
* (unused in mysql)
|
||||
*/
|
||||
public function disableUser($username = null, $host = null) {
|
||||
public function disableUser($username = null, $host = null)
|
||||
{
|
||||
$stmt = Database::prepare('REVOKE ALL PRIVILEGES, GRANT OPTION FROM `' . $username . '`@`' . $host . '`');
|
||||
Database::pexecute($stmt, array(), false);
|
||||
}
|
||||
@@ -161,27 +190,30 @@ class DbManagerMySQL {
|
||||
* @param string $username
|
||||
* @param string $host
|
||||
*/
|
||||
public function enableUser($username = null, $host = null) {
|
||||
Database::query('GRANT ALL PRIVILEGES ON `' . $username .'`.* TO `' . $username . '`@`' . $host . '`');
|
||||
public function enableUser($username = null, $host = null)
|
||||
{
|
||||
Database::query('GRANT ALL PRIVILEGES ON `' . $username . '`.* TO `' . $username . '`@`' . $host . '`');
|
||||
Database::query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $username) . '` . * TO `' . $username . '`@`' . $host . '`');
|
||||
}
|
||||
|
||||
/**
|
||||
* flushes the privileges...pretty obvious eh?
|
||||
*/
|
||||
public function flushPrivileges() {
|
||||
public function flushPrivileges()
|
||||
{
|
||||
Database::query("FLUSH PRIVILEGES");
|
||||
}
|
||||
|
||||
/**
|
||||
* return an array of all usernames used in that DBMS
|
||||
*
|
||||
* @param bool $user_only if false, * will be selected from mysql.user and slightly different array will be generated
|
||||
*
|
||||
* @param bool $user_only
|
||||
* if false, * will be selected from mysql.user and slightly different array will be generated
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllSqlUsers($user_only = true) {
|
||||
|
||||
public function getAllSqlUsers($user_only = true)
|
||||
{
|
||||
if ($user_only == false) {
|
||||
$result_stmt = Database::prepare('SELECT * FROM mysql.user');
|
||||
} else {
|
||||
@@ -189,14 +221,12 @@ class DbManagerMySQL {
|
||||
}
|
||||
Database::pexecute($result_stmt);
|
||||
$allsqlusers = array();
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if ($user_only == false) {
|
||||
if (!isset($allsqlusers[$row['User']])
|
||||
|| !is_array($allsqlusers[$row['User']])
|
||||
) {
|
||||
if (! isset($allsqlusers[$row['User']]) || ! is_array($allsqlusers[$row['User']])) {
|
||||
$allsqlusers[$row['User']] = array(
|
||||
'password' => $row['Password'],
|
||||
'hosts' => array()
|
||||
'password' => $row['Password'],
|
||||
'hosts' => array()
|
||||
);
|
||||
}
|
||||
$allsqlusers[$row['User']]['hosts'][] = $row['Host'];
|
||||
@@ -206,5 +236,4 @@ class DbManagerMySQL {
|
||||
}
|
||||
return $allsqlusers;
|
||||
}
|
||||
|
||||
}
|
||||
119
lib/Froxlor/Idna/IdnaWrapper.php
Normal file
119
lib/Froxlor/Idna/IdnaWrapper.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace Froxlor\Idna;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Michael Duergner <michael@duergner.com> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Classes
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for wrapping a specific idna conversion class and offering a standard interface
|
||||
*
|
||||
* @package Functions
|
||||
*/
|
||||
class IdnaWrapper
|
||||
{
|
||||
|
||||
/**
|
||||
* idna converter we use
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $idna_converter;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* Creates a new idna converter
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Instantiate it
|
||||
$this->idna_converter = new \Mso\IdnaConvert\IdnaConvert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a domain name, a email address or a list of one of both.
|
||||
*
|
||||
* @param
|
||||
* string May be either a single domain name, e single email address or a list of one
|
||||
* separated either by ',', ';' or ' '.
|
||||
*
|
||||
* @return string Returns either a single domain name, a single email address or a list of one of
|
||||
* both separated by the same string as the input.
|
||||
*/
|
||||
public function encode($to_encode)
|
||||
{
|
||||
$to_encode = $this->is_utf8($to_encode) ? $to_encode : utf8_encode($to_encode);
|
||||
return $this->idna_converter->encode($to_encode);
|
||||
}
|
||||
|
||||
public function encode_uri($to_encode)
|
||||
{
|
||||
$to_encode = $this->is_utf8($to_encode) ? $to_encode : utf8_encode($to_encode);
|
||||
return $this->idna_converter->encodeUri($to_encode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a domain name, a email address or a list of one of both.
|
||||
*
|
||||
* @param
|
||||
* string May be either a single domain name, e single email address or a list of one
|
||||
* separated either by ',', ';' or ' '.
|
||||
*
|
||||
* @return string Returns either a single domain name, a single email address or a list of one of
|
||||
* both separated by the same string as the input.
|
||||
*/
|
||||
public function decode($to_decode)
|
||||
{
|
||||
return $this->idna_converter->decode($to_decode);
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether a string is utf-8 encoded or not
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_utf8($string = null)
|
||||
{
|
||||
if (function_exists("mb_detect_encoding")) {
|
||||
if (mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$strlen = strlen($string);
|
||||
for ($i = 0; $i < $strlen; $i ++) {
|
||||
$ord = ord($string[$i]);
|
||||
if ($ord < 0x80)
|
||||
continue; // 0bbbbbbb
|
||||
elseif (($ord & 0xE0) === 0xC0 && $ord > 0xC1)
|
||||
$n = 1; // 110bbbbb (exkl C0-C1)
|
||||
elseif (($ord & 0xF0) === 0xE0)
|
||||
$n = 2; // 1110bbbb
|
||||
elseif (($ord & 0xF8) === 0xF0 && $ord < 0xF5)
|
||||
$n = 3; // 11110bbb (exkl F5-FF)
|
||||
else
|
||||
return false; // ungültiges UTF-8-Zeichen
|
||||
for ($c = 0; $c < $n; $c ++) // $n Folgebytes? // 10bbbbbb
|
||||
if (++ $i === $strlen || (ord($string[$i]) & 0xC0) !== 0x80)
|
||||
// ungültiges UTF-8-Zeichen
|
||||
return false;
|
||||
}
|
||||
// kein ungültiges UTF-8-Zeichen gefunden
|
||||
return true;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,206 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Michael Duergner <michael@duergner.com> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Classes
|
||||
*
|
||||
*/
|
||||
|
||||
// Source for updates: https://github.com/phlylabs/idna-convert.git
|
||||
|
||||
/**
|
||||
* Class for wrapping a specific idna conversion class and offering a standard interface
|
||||
* @package Functions
|
||||
*/
|
||||
class idna_convert_wrapper
|
||||
{
|
||||
/**
|
||||
* idna converter we use
|
||||
* @var object
|
||||
*/
|
||||
|
||||
private $idna_converter;
|
||||
|
||||
/**
|
||||
* Class constructor. Creates a new idna converter
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Instantiate it
|
||||
if (version_compare("5.6.0", PHP_VERSION, ">=")) {
|
||||
$this->idna_converter = new idna_convert(array('idn_version' => '2008', 'encode_german_sz' => false));
|
||||
} else {
|
||||
// use this when using new version of IdnaConverter (which does not work yet)
|
||||
$this->idna_converter = new Mso\IdnaConvert\IdnaConvert();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a domain name, a email address or a list of one of both.
|
||||
*
|
||||
* @param string May be either a single domain name, e single email address or a list of one
|
||||
* separated either by ',', ';' or ' '.
|
||||
*
|
||||
* @return string Returns either a single domain name, a single email address or a list of one of
|
||||
* both separated by the same string as the input.
|
||||
*/
|
||||
|
||||
public function encode($to_encode)
|
||||
{
|
||||
if (version_compare("5.6.0", PHP_VERSION, ">=")) {
|
||||
return $this->_do_action('encode', $to_encode);
|
||||
} else {
|
||||
$to_encode = $this->is_utf8($to_encode) ? $to_encode : utf8_encode($to_encode);
|
||||
return $this->idna_converter->encode($to_encode);
|
||||
}
|
||||
}
|
||||
|
||||
public function encode_uri($to_encode)
|
||||
{
|
||||
if (version_compare("5.6.0", PHP_VERSION, ">=")) {
|
||||
return $this->_do_action('encode', $to_encode);
|
||||
} else {
|
||||
$to_encode = $this->is_utf8($to_encode) ? $to_encode : utf8_encode($to_encode);
|
||||
return $this->idna_converter->encodeUri($to_encode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a domain name, a email address or a list of one of both.
|
||||
*
|
||||
* @param string May be either a single domain name, e single email address or a list of one
|
||||
* separated either by ',', ';' or ' '.
|
||||
*
|
||||
* @return string Returns either a single domain name, a single email address or a list of one of
|
||||
* both separated by the same string as the input.
|
||||
*/
|
||||
|
||||
public function decode($to_decode)
|
||||
{
|
||||
if (version_compare("5.6.0", PHP_VERSION, ">=")) {
|
||||
return $this->_do_action('decode', $to_decode);
|
||||
} else {
|
||||
return $this->idna_converter->decode($to_decode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether a string is utf-8 encoded or not
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_utf8($string = null) {
|
||||
|
||||
if (function_exists("mb_detect_encoding")) {
|
||||
if (mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$strlen = strlen($string);
|
||||
for ($i = 0; $i < $strlen; $i ++) {
|
||||
$ord = ord($string[$i]);
|
||||
if ($ord < 0x80)
|
||||
continue; // 0bbbbbbb
|
||||
elseif (($ord & 0xE0) === 0xC0 && $ord > 0xC1)
|
||||
$n = 1; // 110bbbbb (exkl C0-C1)
|
||||
elseif (($ord & 0xF0) === 0xE0)
|
||||
$n = 2; // 1110bbbb
|
||||
elseif (($ord & 0xF8) === 0xF0 && $ord < 0xF5)
|
||||
$n = 3; // 11110bbb (exkl F5-FF)
|
||||
else
|
||||
return false; // ungültiges UTF-8-Zeichen
|
||||
for ($c = 0; $c < $n; $c ++) // $n Folgebytes? // 10bbbbbb
|
||||
if (++ $i === $strlen || (ord($string[$i]) & 0xC0) !== 0x80)
|
||||
// ungültiges UTF-8-Zeichen
|
||||
return false;
|
||||
}
|
||||
// kein ungültiges UTF-8-Zeichen gefunden
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the real de- or encoding. First checks if a list is submitted and separates it. Afterwards sends
|
||||
* each entry to the idna converter to do the converting.
|
||||
*
|
||||
* @param string May be either 'decode' or 'encode'.
|
||||
* @param string The string to de- or endcode.
|
||||
*
|
||||
* @return string The input string after being processed.
|
||||
*/
|
||||
|
||||
private function _do_action($action, $string)
|
||||
{
|
||||
$string = trim($string);
|
||||
|
||||
if(strpos($string, ',') !== false)
|
||||
{
|
||||
$strings = explode(',', $string);
|
||||
$sepchar = ',';
|
||||
}
|
||||
elseif(strpos($string, ';') !== false)
|
||||
{
|
||||
$strings = explode(';', $string);
|
||||
$sepchar = ';';
|
||||
}
|
||||
elseif(strpos($string, ' ') !== false)
|
||||
{
|
||||
$strings = explode(' ', $string);
|
||||
$sepchar = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$strings = array(
|
||||
$string
|
||||
);
|
||||
$sepchar = '';
|
||||
}
|
||||
|
||||
for ($i = 0;$i < count($strings);$i++)
|
||||
{
|
||||
if(strpos($strings[$i], '@') !== false)
|
||||
{
|
||||
$split = explode('@', $strings[$i]);
|
||||
$localpart = $split[0];
|
||||
$domain = $split[1];
|
||||
$email = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$domain = $strings[$i];
|
||||
$email = false;
|
||||
}
|
||||
|
||||
if(strlen($domain) !== 0)
|
||||
{
|
||||
$domain = $this->idna_converter->$action($domain . '.none');
|
||||
$domain = substr($domain, 0, strlen($domain) - 5);
|
||||
}
|
||||
|
||||
if($email)
|
||||
{
|
||||
$strings[$i] = $localpart . '@' . $domain;
|
||||
}
|
||||
else
|
||||
{
|
||||
$strings[$i] = $domain;
|
||||
}
|
||||
}
|
||||
|
||||
return implode($sepchar, $strings);
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Encoding Helper - convert various encodings to / from UTF-8
|
||||
* @package IDNA Convert
|
||||
* @subpackage charset transcoding
|
||||
* @author Matthias Sommerfeld, <mso@phlylabs.de>
|
||||
* @copyright 2003-2016 phlyLabs Berlin, http://phlylabs.de
|
||||
* @version 1.0.0 2016-01-08
|
||||
*/
|
||||
|
||||
namespace Mso\IdnaConvert;
|
||||
|
||||
class EncodingHelper
|
||||
{
|
||||
/**
|
||||
* Convert a string from any of various encodings to UTF-8
|
||||
*
|
||||
* @param string $string String to encode
|
||||
*[@param string $encoding Encoding; Default: ISO-8859-1]
|
||||
*[@param bool $safe_mode Safe Mode: if set to TRUE, the original string is retunred on errors]
|
||||
* @return string|false The encoded string or false on failure
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static function toUtf8($string = '', $encoding = 'iso-8859-1', $safe_mode = false)
|
||||
{
|
||||
$safe = ($safe_mode) ? $string : false;
|
||||
if (strtoupper($encoding) == 'UTF-8' || strtoupper($encoding) == 'UTF8') {
|
||||
|
||||
return $string;
|
||||
}
|
||||
if (strtoupper($encoding) == 'ISO-8859-1') {
|
||||
|
||||
return \utf8_encode($string);
|
||||
|
||||
} if (strtoupper($encoding) == 'WINDOWS-1252') {
|
||||
|
||||
return \utf8_encode(self::map_w1252_iso8859_1($string));
|
||||
}
|
||||
|
||||
if (strtoupper($encoding) == 'UNICODE-1-1-UTF-7') {
|
||||
$encoding = 'utf-7';
|
||||
}
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
$conv = @mb_convert_encoding($string, 'UTF-8', strtoupper($encoding));
|
||||
if ($conv) {
|
||||
|
||||
return $conv;
|
||||
}
|
||||
}
|
||||
if (function_exists('iconv')) {
|
||||
$conv = @iconv(strtoupper($encoding), 'UTF-8', $string);
|
||||
if ($conv) {
|
||||
|
||||
return $conv;
|
||||
}
|
||||
}
|
||||
if (function_exists('libiconv')) {
|
||||
$conv = @libiconv(strtoupper($encoding), 'UTF-8', $string);
|
||||
if ($conv) {
|
||||
|
||||
return $conv;
|
||||
}
|
||||
}
|
||||
|
||||
return $safe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string from UTF-8 to any of various encodings
|
||||
*
|
||||
* @param string $string String to decode
|
||||
*[@param string $encoding Encoding; Default: ISO-8859-1]
|
||||
*[@param bool $safe_mode Safe Mode: if set to TRUE, the original string is retunred on errors]
|
||||
* @return string|false The decoded string or false on failure
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static function fromUtf8($string = '', $encoding = 'iso-8859-1', $safe_mode = false)
|
||||
{
|
||||
$safe = ($safe_mode) ? $string : false;
|
||||
if (!$encoding) $encoding = 'ISO-8859-1';
|
||||
if (strtoupper($encoding) == 'UTF-8' || strtoupper($encoding) == 'UTF8') {
|
||||
|
||||
return $string;
|
||||
}
|
||||
if (strtoupper($encoding) == 'ISO-8859-1') {
|
||||
|
||||
return utf8_decode($string);
|
||||
}
|
||||
if (strtoupper($encoding) == 'WINDOWS-1252') {
|
||||
|
||||
return self::map_iso8859_1_w1252(utf8_decode($string));
|
||||
}
|
||||
|
||||
if (strtoupper($encoding) == 'UNICODE-1-1-UTF-7') {
|
||||
$encoding = 'utf-7';
|
||||
}
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
$conv = @mb_convert_encoding($string, strtoupper($encoding), 'UTF-8');
|
||||
if ($conv) {
|
||||
|
||||
return $conv;
|
||||
}
|
||||
}
|
||||
if (function_exists('iconv')) {
|
||||
$conv = @iconv('UTF-8', strtoupper($encoding), $string);
|
||||
if ($conv) {
|
||||
|
||||
return $conv;
|
||||
}
|
||||
}
|
||||
if (function_exists('libiconv')) {
|
||||
$conv = @libiconv('UTF-8', strtoupper($encoding), $string);
|
||||
if ($conv) {
|
||||
|
||||
return $conv;
|
||||
}
|
||||
}
|
||||
|
||||
return $safe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special treatment for our guys in Redmond
|
||||
* Windows-1252 is basically ISO-8859-1 -- with some exceptions, which get accounted for here
|
||||
*
|
||||
* @param string $string Your input in Win1252
|
||||
* @return string The resulting ISO-8859-1 string
|
||||
* @since 0.0.1
|
||||
*/
|
||||
protected static function map_w1252_iso8859_1($string = '')
|
||||
{
|
||||
if ($string == '') {
|
||||
|
||||
return '';
|
||||
}
|
||||
$return = '';
|
||||
|
||||
for ($i = 0; $i < strlen($string); ++$i) {
|
||||
$c = ord($string{$i});
|
||||
switch ($c) {
|
||||
case 129: $return .= chr(252); break;
|
||||
case 132: $return .= chr(228); break;
|
||||
case 142: $return .= chr(196); break;
|
||||
case 148: $return .= chr(246); break;
|
||||
case 153: $return .= chr(214); break;
|
||||
case 154: $return .= chr(220); break;
|
||||
case 225: $return .= chr(223); break;
|
||||
default: $return .= chr($c);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special treatment for our guys in Redmond
|
||||
* Windows-1252 is basically ISO-8859-1 -- with some exceptions, which get accounted for here
|
||||
*
|
||||
* @param string $string Your input in ISO-8859-1
|
||||
* @return string The resulting Win1252 string
|
||||
* @since 0.0.1
|
||||
*/
|
||||
protected static function map_iso8859_1_w1252($string = '')
|
||||
{
|
||||
if ($string == '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$return = '';
|
||||
for ($i = 0; $i < strlen($string); ++$i) {
|
||||
$c = ord($string{$i});
|
||||
switch ($c) {
|
||||
case 196: $return .= chr(142); break;
|
||||
case 214: $return .= chr(153); break;
|
||||
case 220: $return .= chr(154); break;
|
||||
case 223: $return .= chr(225); break;
|
||||
case 228: $return .= chr(132); break;
|
||||
case 246: $return .= chr(148); break;
|
||||
case 252: $return .= chr(129); break;
|
||||
default: $return .= chr($c);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -1,405 +0,0 @@
|
||||
<?php
|
||||
|
||||
// {{{ license
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This library is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU Lesser General Public License as |
|
||||
// | published by the Free Software Foundation; either version 2.1 of the |
|
||||
// | License, or (at your option) any later version. |
|
||||
// | |
|
||||
// | This library is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | Lesser General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU Lesser General Public |
|
||||
// | License along with this library; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 51 Franklin St, Boston, MA 02110, United States |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// }}}
|
||||
|
||||
/**
|
||||
* Encode/decode Internationalized Domain Names.
|
||||
*
|
||||
* The class allows to convert internationalized domain names
|
||||
* (see RFC 3490 for details) as they can be used with various registries worldwide
|
||||
* to be translated between their original (localized) form and their encoded form
|
||||
* as it will be used in the DNS (Domain Name System).
|
||||
*
|
||||
* The class provides two public methods, encode() and decode(), which do exactly
|
||||
* what you would expect them to do. You are allowed to use complete domain names,
|
||||
* simple strings and complete email addresses as well. That means, that you might
|
||||
* use any of the following notations:
|
||||
*
|
||||
* - www.nörgler.com
|
||||
* - xn--nrgler-wxa
|
||||
* - xn--brse-5qa.xn--knrz-1ra.info
|
||||
*
|
||||
* Unicode input might be given as either UTF-8 string, UCS-4 string or UCS-4 array.
|
||||
* Unicode output is available in the same formats.
|
||||
* You can select your preferred format via {@link set_paramter()}.
|
||||
*
|
||||
* ACE input and output is always expected to be ASCII.
|
||||
*
|
||||
* @author Matthias Sommerfeld <mso@phlylabs.de>
|
||||
* @copyright 2004-2016 phlyLabs Berlin, http://phlylabs.de
|
||||
* @version 1.0.1-dev 2016-01-12
|
||||
*/
|
||||
|
||||
namespace Mso\IdnaConvert;
|
||||
|
||||
class IdnaConvert {
|
||||
|
||||
const Version = '1.1.0';
|
||||
const SubVersion = 'main';
|
||||
|
||||
// Internal settings, do not touch!
|
||||
protected $encoding = 'utf8'; // Default input charset is UTF-8
|
||||
protected $strictMode = false; // Behave strict or not
|
||||
protected $idnVersion = '2008'; // Can be either 2003 (old) or 2008 (default)
|
||||
|
||||
protected $NamePrepData = null;
|
||||
protected $UnicodeTranscoder = null;
|
||||
|
||||
/**
|
||||
* the constructor
|
||||
*
|
||||
* @param array|null $params Parameters to control the class' behaviour
|
||||
* @since 0.5.2
|
||||
*/
|
||||
public function __construct($params = null)
|
||||
{
|
||||
$this->UnicodeTranscoder = new UnicodeTranscoder();
|
||||
|
||||
// Kept for backwarsds compatibility. Consider using the setter methods instead.
|
||||
if (!empty($params) && is_array($params)) {
|
||||
if (isset($params['encoding'])) {
|
||||
$this->setEncoding($params['encoding']);
|
||||
}
|
||||
|
||||
if (isset($params['idn_version'])) {
|
||||
$this->setIdnVersion($params['idn_version']);
|
||||
}
|
||||
|
||||
if (isset($params['strict_mode'])) {
|
||||
$this->setStrictMode($params['strict_mode']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->setIdnVersion($this->idnVersion);
|
||||
}
|
||||
|
||||
public function getClassVersion()
|
||||
{
|
||||
return self::Version.'-'.self::SubVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
return $this->encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $encoding
|
||||
*/
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
switch ($encoding) {
|
||||
case 'utf8':
|
||||
case 'ucs4_string':
|
||||
case 'ucs4_array':
|
||||
$this->encoding = $encoding;
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Invalid encoding %s', $encoding));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isStrictMode()
|
||||
{
|
||||
return $this->strictMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $strictMode
|
||||
*/
|
||||
public function setStrictMode($strictMode)
|
||||
{
|
||||
$this->strictMode = ($strictMode) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIdnVersion()
|
||||
{
|
||||
return $this->idnVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $idnVersion
|
||||
*/
|
||||
public function setIdnVersion($idnVersion)
|
||||
{
|
||||
if (in_array($idnVersion, ['2003', '2008'])) {
|
||||
if (is_null($this->NamePrepData) || $idnVersion != $this->idnVersion) {
|
||||
$this->NamePrepData = null; // Ought to destroy the object's reference
|
||||
// Re-instantiate with different data set
|
||||
$this->NamePrepData = ($idnVersion == 2003)
|
||||
? new NamePrepData2003()
|
||||
: new NamePrepData();
|
||||
}
|
||||
|
||||
$this->idnVersion = $idnVersion;
|
||||
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid IDN version %d', $idnVersion));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a given ACE domain name
|
||||
* @param string $input Domain name (ACE string)
|
||||
* [@param string $one_time_encoding Desired output encoding]
|
||||
* @return string Decoded Domain name (UTF-8 or UCS-4)
|
||||
*/
|
||||
public function decode($input, $one_time_encoding = null)
|
||||
{
|
||||
$punyCode = $this->punycodeFactory();
|
||||
|
||||
// Optionally set
|
||||
if ($one_time_encoding) {
|
||||
switch ($one_time_encoding) {
|
||||
case 'utf8':
|
||||
case 'ucs4_string':
|
||||
case 'ucs4_array':
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Invalid encoding %s', $one_time_encoding));
|
||||
}
|
||||
}
|
||||
// Make sure to drop any newline characters around
|
||||
$input = trim($input);
|
||||
|
||||
// Negotiate input and try to determine, whether it is a plain string,
|
||||
// an email address or something like a complete URL
|
||||
if (strpos($input, '@')) { // Maybe it is an email address
|
||||
// No no in strict mode
|
||||
if ($this->strictMode) {
|
||||
throw new \InvalidArgumentException('Only individual domain name parts can be handled in strict mode');
|
||||
}
|
||||
list ($email_pref, $input) = explode('@', $input, 2);
|
||||
$arr = explode('.', $input);
|
||||
foreach ($arr as $k => $v) {
|
||||
$conv = $punyCode->decode($v);
|
||||
if ($conv) {
|
||||
$arr[$k] = $conv;
|
||||
}
|
||||
}
|
||||
$input = join('.', $arr);
|
||||
$arr = explode('.', $email_pref);
|
||||
foreach ($arr as $k => $v) {
|
||||
$conv = $punyCode->decode($v);
|
||||
if ($conv) {
|
||||
$arr[$k] = $conv;
|
||||
}
|
||||
}
|
||||
$email_pref = join('.', $arr);
|
||||
$return = $email_pref . '@' . $input;
|
||||
} elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters)
|
||||
// No no in strict mode
|
||||
if ($this->strictMode) {
|
||||
throw new \InvalidArgumentException('Only individual domain name parts can be handled in strict mode');
|
||||
}
|
||||
$parsed = parse_url($input);
|
||||
if (isset($parsed['host'])) {
|
||||
$arr = explode('.', $parsed['host']);
|
||||
foreach ($arr as $k => $v) {
|
||||
$conv = $punyCode->decode($v);
|
||||
if ($conv) {
|
||||
$arr[$k] = $conv;
|
||||
}
|
||||
}
|
||||
$parsed['host'] = join('.', $arr);
|
||||
$return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
|
||||
(empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@').
|
||||
$parsed['host'].
|
||||
(empty($parsed['port']) ? '' : ':' . $parsed['port']).
|
||||
(empty($parsed['path']) ? '' : $parsed['path']).
|
||||
(empty($parsed['query']) ? '' : '?' . $parsed['query']).
|
||||
(empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']);
|
||||
} else { // parse_url seems to have failed, try without it
|
||||
$arr = explode('.', $input);
|
||||
foreach ($arr as $k => $v) {
|
||||
$conv = $punyCode->decode($v);
|
||||
if ($conv) {
|
||||
$arr[$k] = $conv;
|
||||
}
|
||||
}
|
||||
$return = join('.', $arr);
|
||||
}
|
||||
} else { // Otherwise we consider it being a pure domain name string
|
||||
$return = $punyCode->decode($input);
|
||||
if (!$return) {
|
||||
$return = $input;
|
||||
}
|
||||
}
|
||||
// The output is UTF-8 by default, other output formats need conversion here
|
||||
// If one time encoding is given, use this, else the objects property
|
||||
$outputEncoding = ($one_time_encoding) ? $one_time_encoding : $this->encoding;
|
||||
switch ($outputEncoding) {
|
||||
case 'utf8':
|
||||
return $return; // break;
|
||||
case 'ucs4_string':
|
||||
return $this->UnicodeTranscoder->convert($return, 'utf8', 'ucs4'); // break;
|
||||
case 'ucs4_array':
|
||||
return $this->UnicodeTranscoder->convert($return, 'utf8', 'ucs4array'); // break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Unsupported output encoding %s', $outputEncoding));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a given UTF-8 domain name
|
||||
* @param string $decoded Domain name (UTF-8 or UCS-4)
|
||||
* [@param boolean $one_time_encoding Desired input encoding, see {@link set_parameter}]
|
||||
* @return string Encoded Domain name (ACE string)
|
||||
*/
|
||||
public function encode($decoded, $one_time_encoding = false)
|
||||
{
|
||||
// Forcing conversion of input to UCS4 array
|
||||
// If one time encoding is given, use this, else the objects property
|
||||
$inputEncoding = $one_time_encoding ? $one_time_encoding : $this->encoding;
|
||||
switch ($inputEncoding) {
|
||||
case 'utf8':
|
||||
$decoded = $this->UnicodeTranscoder->convert($decoded, 'utf8', 'ucs4array');
|
||||
break;
|
||||
case 'ucs4_string':
|
||||
$decoded = $this->UnicodeTranscoder->convert($decoded, 'ucs4', 'ucs4array');
|
||||
break;
|
||||
case 'ucs4_array':
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Unsupported input encoding %s', $inputEncoding));
|
||||
}
|
||||
|
||||
// No input, no output, what else did you expect?
|
||||
if (empty($decoded)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$punyCode = $this->punycodeFactory();
|
||||
|
||||
// Anchors for iteration
|
||||
$last_begin = 0;
|
||||
// Output string
|
||||
$output = '';
|
||||
foreach ($decoded as $k => $v) {
|
||||
// Make sure to use just the plain dot
|
||||
switch ($v) {
|
||||
case 0x3002:
|
||||
case 0xFF0E:
|
||||
case 0xFF61:
|
||||
$decoded[$k] = 0x2E;
|
||||
// Right, no break here, the above are converted to dots anyway
|
||||
// Stumbling across an anchoring character
|
||||
case 0x2E:
|
||||
case 0x2F:
|
||||
case 0x3A:
|
||||
case 0x3F:
|
||||
case 0x40:
|
||||
// Neither email addresses nor URLs allowed in strict mode
|
||||
if ($this->strictMode) {
|
||||
throw new \InvalidArgumentException('Neither email addresses nor URLs are allowed in strict mode.');
|
||||
} else {
|
||||
// Skip first char
|
||||
if ($k) {
|
||||
$encoded = $punyCode->encode(array_slice($decoded, $last_begin, (($k) - $last_begin)));
|
||||
if ($encoded) {
|
||||
$output .= $encoded;
|
||||
} else {
|
||||
$output .= $this->UnicodeTranscoder->convert(array_slice($decoded, $last_begin, (($k) - $last_begin)), 'ucs4array', 'utf8');
|
||||
}
|
||||
$output .= chr($decoded[$k]);
|
||||
}
|
||||
$last_begin = $k + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Catch the rest of the string
|
||||
if ($last_begin) {
|
||||
$inp_len = sizeof($decoded);
|
||||
$encoded = $punyCode->encode(array_slice($decoded, $last_begin, (($inp_len) - $last_begin)));
|
||||
if ($encoded) {
|
||||
$output .= $encoded;
|
||||
} else {
|
||||
$output .= $this->UnicodeTranscoder->convert(array_slice($decoded, $last_begin, (($inp_len) - $last_begin)), 'ucs4array', 'utf8');
|
||||
}
|
||||
return $output;
|
||||
} else {
|
||||
if (false !== ($output = $punyCode->encode($decoded))) {
|
||||
return $output;
|
||||
} else {
|
||||
return $this->UnicodeTranscoder->convert($decoded, 'ucs4array', 'utf8');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mitigates a weakness of encode(), which cannot properly handle URIs but instead encodes their
|
||||
* path or query components, too.
|
||||
* @param string $uri Expects the URI as a UTF-8 (or ASCII) string
|
||||
* @return string The URI encoded to Punycode, everything but the host component is left alone
|
||||
* @since 0.6.4
|
||||
*/
|
||||
public function encodeUri($uri)
|
||||
{
|
||||
$parsed = parse_url($uri);
|
||||
if (!isset($parsed['host'])) {
|
||||
throw new \InvalidArgumentException('The given string does not look like a URI');
|
||||
}
|
||||
$arr = explode('.', $parsed['host']);
|
||||
foreach ($arr as $k => $v) {
|
||||
$conv = $this->encode($v, 'utf8');
|
||||
if ($conv) {
|
||||
$arr[$k] = $conv;
|
||||
}
|
||||
}
|
||||
$parsed['host'] = join('.', $arr);
|
||||
$return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
|
||||
(empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@').
|
||||
$parsed['host'].
|
||||
(empty($parsed['port']) ? '' : ':' . $parsed['port']).
|
||||
(empty($parsed['path']) ? '' : $parsed['path']).
|
||||
(empty($parsed['query']) ? '' : '?' . $parsed['query']).
|
||||
(empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']);
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual punycode class is rather costly, as well as passing the huge nameprep database around.
|
||||
* This factory method allows to ease the burden when dealing with multiple IDN versions.
|
||||
*
|
||||
* @return \Mso\IdnaConvert\Punycode
|
||||
*/
|
||||
protected function punycodeFactory()
|
||||
{
|
||||
static $instances = [];
|
||||
|
||||
if (!isset($instances[$this->idnVersion])) {
|
||||
$instances[$this->idnVersion] = new Punycode($this->NamePrepData, $this->UnicodeTranscoder);
|
||||
}
|
||||
return $instances[$this->idnVersion];
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,501 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Mso\IdnaConvert;
|
||||
|
||||
class NamePrepData2003 extends NamePrepData implements NamePrepDataInterface
|
||||
{
|
||||
public $replaceMaps = [
|
||||
0x41 => [0x61], 0x42 => [0x62], 0x43 => [0x63],
|
||||
0x44 => [0x64], 0x45 => [0x65], 0x46 => [0x66], 0x47 => [0x67],
|
||||
0x48 => [0x68], 0x49 => [0x69], 0x4A => [0x6A], 0x4B => [0x6B],
|
||||
0x4C => [0x6C], 0x4D => [0x6D], 0x4E => [0x6E], 0x4F => [0x6F],
|
||||
0x50 => [0x70], 0x51 => [0x71], 0x52 => [0x72], 0x53 => [0x73],
|
||||
0x54 => [0x74], 0x55 => [0x75], 0x56 => [0x76], 0x57 => [0x77],
|
||||
0x58 => [0x78], 0x59 => [0x79], 0x5A => [0x7A], 0xB5 => [0x3BC],
|
||||
0xC0 => [0xE0], 0xC1 => [0xE1], 0xC2 => [0xE2], 0xC3 => [0xE3],
|
||||
0xC4 => [0xE4], 0xC5 => [0xE5], 0xC6 => [0xE6], 0xC7 => [0xE7],
|
||||
0xC8 => [0xE8], 0xC9 => [0xE9], 0xCA => [0xEA], 0xCB => [0xEB],
|
||||
0xCC => [0xEC], 0xCD => [0xED], 0xCE => [0xEE], 0xCF => [0xEF],
|
||||
0xD0 => [0xF0], 0xD1 => [0xF1], 0xD2 => [0xF2], 0xD3 => [0xF3],
|
||||
0xD4 => [0xF4], 0xD5 => [0xF5], 0xD6 => [0xF6], 0xD8 => [0xF8],
|
||||
0xD9 => [0xF9], 0xDA => [0xFA], 0xDB => [0xFB], 0xDC => [0xFC],
|
||||
0xDD => [0xFD], 0xDE => [0xFE], 0xDF => [0x73, 0x73],
|
||||
0x100 => [0x101], 0x102 => [0x103], 0x104 => [0x105],
|
||||
0x106 => [0x107], 0x108 => [0x109], 0x10A => [0x10B],
|
||||
0x10C => [0x10D], 0x10E => [0x10F], 0x110 => [0x111],
|
||||
0x112 => [0x113], 0x114 => [0x115], 0x116 => [0x117],
|
||||
0x118 => [0x119], 0x11A => [0x11B], 0x11C => [0x11D],
|
||||
0x11E => [0x11F], 0x120 => [0x121], 0x122 => [0x123],
|
||||
0x124 => [0x125], 0x126 => [0x127], 0x128 => [0x129],
|
||||
0x12A => [0x12B], 0x12C => [0x12D], 0x12E => [0x12F],
|
||||
0x130 => [0x69, 0x307], 0x132 => [0x133], 0x134 => [0x135],
|
||||
0x136 => [0x137], 0x139 => [0x13A], 0x13B => [0x13C],
|
||||
0x13D => [0x13E], 0x13F => [0x140], 0x141 => [0x142],
|
||||
0x143 => [0x144], 0x145 => [0x146], 0x147 => [0x148],
|
||||
0x149 => [0x2BC, 0x6E], 0x14A => [0x14B], 0x14C => [0x14D],
|
||||
0x14E => [0x14F], 0x150 => [0x151], 0x152 => [0x153],
|
||||
0x154 => [0x155], 0x156 => [0x157], 0x158 => [0x159],
|
||||
0x15A => [0x15B], 0x15C => [0x15D], 0x15E => [0x15F],
|
||||
0x160 => [0x161], 0x162 => [0x163], 0x164 => [0x165],
|
||||
0x166 => [0x167], 0x168 => [0x169], 0x16A => [0x16B],
|
||||
0x16C => [0x16D], 0x16E => [0x16F], 0x170 => [0x171],
|
||||
0x172 => [0x173], 0x174 => [0x175], 0x176 => [0x177],
|
||||
0x178 => [0xFF], 0x179 => [0x17A], 0x17B => [0x17C],
|
||||
0x17D => [0x17E], 0x17F => [0x73], 0x181 => [0x253],
|
||||
0x182 => [0x183], 0x184 => [0x185], 0x186 => [0x254],
|
||||
0x187 => [0x188], 0x189 => [0x256], 0x18A => [0x257],
|
||||
0x18B => [0x18C], 0x18E => [0x1DD], 0x18F => [0x259],
|
||||
0x190 => [0x25B], 0x191 => [0x192], 0x193 => [0x260],
|
||||
0x194 => [0x263], 0x196 => [0x269], 0x197 => [0x268],
|
||||
0x198 => [0x199], 0x19C => [0x26F], 0x19D => [0x272],
|
||||
0x19F => [0x275], 0x1A0 => [0x1A1], 0x1A2 => [0x1A3],
|
||||
0x1A4 => [0x1A5], 0x1A6 => [0x280], 0x1A7 => [0x1A8],
|
||||
0x1A9 => [0x283], 0x1AC => [0x1AD], 0x1AE => [0x288],
|
||||
0x1AF => [0x1B0], 0x1B1 => [0x28A], 0x1B2 => [0x28B],
|
||||
0x1B3 => [0x1B4], 0x1B5 => [0x1B6], 0x1B7 => [0x292],
|
||||
0x1B8 => [0x1B9], 0x1BC => [0x1BD], 0x1C4 => [0x1C6],
|
||||
0x1C5 => [0x1C6], 0x1C7 => [0x1C9], 0x1C8 => [0x1C9],
|
||||
0x1CA => [0x1CC], 0x1CB => [0x1CC], 0x1CD => [0x1CE],
|
||||
0x1CF => [0x1D0], 0x1D1 => [0x1D2], 0x1D3 => [0x1D4],
|
||||
0x1D5 => [0x1D6], 0x1D7 => [0x1D8], 0x1D9 => [0x1DA],
|
||||
0x1DB => [0x1DC], 0x1DE => [0x1DF], 0x1E0 => [0x1E1],
|
||||
0x1E2 => [0x1E3], 0x1E4 => [0x1E5], 0x1E6 => [0x1E7],
|
||||
0x1E8 => [0x1E9], 0x1EA => [0x1EB], 0x1EC => [0x1ED],
|
||||
0x1EE => [0x1EF], 0x1F0 => [0x6A, 0x30C], 0x1F1 => [0x1F3],
|
||||
0x1F2 => [0x1F3], 0x1F4 => [0x1F5], 0x1F6 => [0x195],
|
||||
0x1F7 => [0x1BF], 0x1F8 => [0x1F9], 0x1FA => [0x1FB],
|
||||
0x1FC => [0x1FD], 0x1FE => [0x1FF], 0x200 => [0x201],
|
||||
0x202 => [0x203], 0x204 => [0x205], 0x206 => [0x207],
|
||||
0x208 => [0x209], 0x20A => [0x20B], 0x20C => [0x20D],
|
||||
0x20E => [0x20F], 0x210 => [0x211], 0x212 => [0x213],
|
||||
0x214 => [0x215], 0x216 => [0x217], 0x218 => [0x219],
|
||||
0x21A => [0x21B], 0x21C => [0x21D], 0x21E => [0x21F],
|
||||
0x220 => [0x19E], 0x222 => [0x223], 0x224 => [0x225],
|
||||
0x226 => [0x227], 0x228 => [0x229], 0x22A => [0x22B],
|
||||
0x22C => [0x22D], 0x22E => [0x22F], 0x230 => [0x231],
|
||||
0x232 => [0x233], 0x345 => [0x3B9], 0x37A => [0x20, 0x3B9],
|
||||
0x386 => [0x3AC], 0x388 => [0x3AD], 0x389 => [0x3AE],
|
||||
0x38A => [0x3AF], 0x38C => [0x3CC], 0x38E => [0x3CD],
|
||||
0x38F => [0x3CE], 0x390 => [0x3B9, 0x308, 0x301],
|
||||
0x391 => [0x3B1], 0x392 => [0x3B2], 0x393 => [0x3B3],
|
||||
0x394 => [0x3B4], 0x395 => [0x3B5], 0x396 => [0x3B6],
|
||||
0x397 => [0x3B7], 0x398 => [0x3B8], 0x399 => [0x3B9],
|
||||
0x39A => [0x3BA], 0x39B => [0x3BB], 0x39C => [0x3BC],
|
||||
0x39D => [0x3BD], 0x39E => [0x3BE], 0x39F => [0x3BF],
|
||||
0x3A0 => [0x3C0], 0x3A1 => [0x3C1], 0x3A3 => [0x3C3],
|
||||
0x3A4 => [0x3C4], 0x3A5 => [0x3C5], 0x3A6 => [0x3C6],
|
||||
0x3A7 => [0x3C7], 0x3A8 => [0x3C8], 0x3A9 => [0x3C9],
|
||||
0x3AA => [0x3CA], 0x3AB => [0x3CB], 0x3B0 => [0x3C5, 0x308, 0x301],
|
||||
0x3C2 => [0x3C3], 0x3D0 => [0x3B2], 0x3D1 => [0x3B8],
|
||||
0x3D2 => [0x3C5], 0x3D3 => [0x3CD], 0x3D4 => [0x3CB],
|
||||
0x3D5 => [0x3C6], 0x3D6 => [0x3C0], 0x3D8 => [0x3D9],
|
||||
0x3DA => [0x3DB], 0x3DC => [0x3DD], 0x3DE => [0x3DF],
|
||||
0x3E0 => [0x3E1], 0x3E2 => [0x3E3], 0x3E4 => [0x3E5],
|
||||
0x3E6 => [0x3E7], 0x3E8 => [0x3E9], 0x3EA => [0x3EB],
|
||||
0x3EC => [0x3ED], 0x3EE => [0x3EF], 0x3F0 => [0x3BA],
|
||||
0x3F1 => [0x3C1], 0x3F2 => [0x3C3], 0x3F4 => [0x3B8],
|
||||
0x3F5 => [0x3B5], 0x400 => [0x450], 0x401 => [0x451],
|
||||
0x402 => [0x452], 0x403 => [0x453], 0x404 => [0x454],
|
||||
0x405 => [0x455], 0x406 => [0x456], 0x407 => [0x457],
|
||||
0x408 => [0x458], 0x409 => [0x459], 0x40A => [0x45A],
|
||||
0x40B => [0x45B], 0x40C => [0x45C], 0x40D => [0x45D],
|
||||
0x40E => [0x45E], 0x40F => [0x45F], 0x410 => [0x430],
|
||||
0x411 => [0x431], 0x412 => [0x432], 0x413 => [0x433],
|
||||
0x414 => [0x434], 0x415 => [0x435], 0x416 => [0x436],
|
||||
0x417 => [0x437], 0x418 => [0x438], 0x419 => [0x439],
|
||||
0x41A => [0x43A], 0x41B => [0x43B], 0x41C => [0x43C],
|
||||
0x41D => [0x43D], 0x41E => [0x43E], 0x41F => [0x43F],
|
||||
0x420 => [0x440], 0x421 => [0x441], 0x422 => [0x442],
|
||||
0x423 => [0x443], 0x424 => [0x444], 0x425 => [0x445],
|
||||
0x426 => [0x446], 0x427 => [0x447], 0x428 => [0x448],
|
||||
0x429 => [0x449], 0x42A => [0x44A], 0x42B => [0x44B],
|
||||
0x42C => [0x44C], 0x42D => [0x44D], 0x42E => [0x44E],
|
||||
0x42F => [0x44F], 0x460 => [0x461], 0x462 => [0x463],
|
||||
0x464 => [0x465], 0x466 => [0x467], 0x468 => [0x469],
|
||||
0x46A => [0x46B], 0x46C => [0x46D], 0x46E => [0x46F],
|
||||
0x470 => [0x471], 0x472 => [0x473], 0x474 => [0x475],
|
||||
0x476 => [0x477], 0x478 => [0x479], 0x47A => [0x47B],
|
||||
0x47C => [0x47D], 0x47E => [0x47F], 0x480 => [0x481],
|
||||
0x48A => [0x48B], 0x48C => [0x48D], 0x48E => [0x48F],
|
||||
0x490 => [0x491], 0x492 => [0x493], 0x494 => [0x495],
|
||||
0x496 => [0x497], 0x498 => [0x499], 0x49A => [0x49B],
|
||||
0x49C => [0x49D], 0x49E => [0x49F], 0x4A0 => [0x4A1],
|
||||
0x4A2 => [0x4A3], 0x4A4 => [0x4A5], 0x4A6 => [0x4A7],
|
||||
0x4A8 => [0x4A9], 0x4AA => [0x4AB], 0x4AC => [0x4AD],
|
||||
0x4AE => [0x4AF], 0x4B0 => [0x4B1], 0x4B2 => [0x4B3],
|
||||
0x4B4 => [0x4B5], 0x4B6 => [0x4B7], 0x4B8 => [0x4B9],
|
||||
0x4BA => [0x4BB], 0x4BC => [0x4BD], 0x4BE => [0x4BF],
|
||||
0x4C1 => [0x4C2], 0x4C3 => [0x4C4], 0x4C5 => [0x4C6],
|
||||
0x4C7 => [0x4C8], 0x4C9 => [0x4CA], 0x4CB => [0x4CC],
|
||||
0x4CD => [0x4CE], 0x4D0 => [0x4D1], 0x4D2 => [0x4D3],
|
||||
0x4D4 => [0x4D5], 0x4D6 => [0x4D7], 0x4D8 => [0x4D9],
|
||||
0x4DA => [0x4DB], 0x4DC => [0x4DD], 0x4DE => [0x4DF],
|
||||
0x4E0 => [0x4E1], 0x4E2 => [0x4E3], 0x4E4 => [0x4E5],
|
||||
0x4E6 => [0x4E7], 0x4E8 => [0x4E9], 0x4EA => [0x4EB],
|
||||
0x4EC => [0x4ED], 0x4EE => [0x4EF], 0x4F0 => [0x4F1],
|
||||
0x4F2 => [0x4F3], 0x4F4 => [0x4F5], 0x4F8 => [0x4F9],
|
||||
0x500 => [0x501], 0x502 => [0x503], 0x504 => [0x505],
|
||||
0x506 => [0x507], 0x508 => [0x509], 0x50A => [0x50B],
|
||||
0x50C => [0x50D], 0x50E => [0x50F], 0x531 => [0x561],
|
||||
0x532 => [0x562], 0x533 => [0x563], 0x534 => [0x564],
|
||||
0x535 => [0x565], 0x536 => [0x566], 0x537 => [0x567],
|
||||
0x538 => [0x568], 0x539 => [0x569], 0x53A => [0x56A],
|
||||
0x53B => [0x56B], 0x53C => [0x56C], 0x53D => [0x56D],
|
||||
0x53E => [0x56E], 0x53F => [0x56F], 0x540 => [0x570],
|
||||
0x541 => [0x571], 0x542 => [0x572], 0x543 => [0x573],
|
||||
0x544 => [0x574], 0x545 => [0x575], 0x546 => [0x576],
|
||||
0x547 => [0x577], 0x548 => [0x578], 0x549 => [0x579],
|
||||
0x54A => [0x57A], 0x54B => [0x57B], 0x54C => [0x57C],
|
||||
0x54D => [0x57D], 0x54E => [0x57E], 0x54F => [0x57F],
|
||||
0x550 => [0x580], 0x551 => [0x581], 0x552 => [0x582],
|
||||
0x553 => [0x583], 0x554 => [0x584], 0x555 => [0x585],
|
||||
0x556 => [0x586], 0x587 => [0x565, 0x582], 0xE33 => [0xE4D, 0xE32],
|
||||
0x1E00 => [0x1E01], 0x1E02 => [0x1E03], 0x1E04 => [0x1E05],
|
||||
0x1E06 => [0x1E07], 0x1E08 => [0x1E09], 0x1E0A => [0x1E0B],
|
||||
0x1E0C => [0x1E0D], 0x1E0E => [0x1E0F], 0x1E10 => [0x1E11],
|
||||
0x1E12 => [0x1E13], 0x1E14 => [0x1E15], 0x1E16 => [0x1E17],
|
||||
0x1E18 => [0x1E19], 0x1E1A => [0x1E1B], 0x1E1C => [0x1E1D],
|
||||
0x1E1E => [0x1E1F], 0x1E20 => [0x1E21], 0x1E22 => [0x1E23],
|
||||
0x1E24 => [0x1E25], 0x1E26 => [0x1E27], 0x1E28 => [0x1E29],
|
||||
0x1E2A => [0x1E2B], 0x1E2C => [0x1E2D], 0x1E2E => [0x1E2F],
|
||||
0x1E30 => [0x1E31], 0x1E32 => [0x1E33], 0x1E34 => [0x1E35],
|
||||
0x1E36 => [0x1E37], 0x1E38 => [0x1E39], 0x1E3A => [0x1E3B],
|
||||
0x1E3C => [0x1E3D], 0x1E3E => [0x1E3F], 0x1E40 => [0x1E41],
|
||||
0x1E42 => [0x1E43], 0x1E44 => [0x1E45], 0x1E46 => [0x1E47],
|
||||
0x1E48 => [0x1E49], 0x1E4A => [0x1E4B], 0x1E4C => [0x1E4D],
|
||||
0x1E4E => [0x1E4F], 0x1E50 => [0x1E51], 0x1E52 => [0x1E53],
|
||||
0x1E54 => [0x1E55], 0x1E56 => [0x1E57], 0x1E58 => [0x1E59],
|
||||
0x1E5A => [0x1E5B], 0x1E5C => [0x1E5D], 0x1E5E => [0x1E5F],
|
||||
0x1E60 => [0x1E61], 0x1E62 => [0x1E63], 0x1E64 => [0x1E65],
|
||||
0x1E66 => [0x1E67], 0x1E68 => [0x1E69], 0x1E6A => [0x1E6B],
|
||||
0x1E6C => [0x1E6D], 0x1E6E => [0x1E6F], 0x1E70 => [0x1E71],
|
||||
0x1E72 => [0x1E73], 0x1E74 => [0x1E75], 0x1E76 => [0x1E77],
|
||||
0x1E78 => [0x1E79], 0x1E7A => [0x1E7B], 0x1E7C => [0x1E7D],
|
||||
0x1E7E => [0x1E7F], 0x1E80 => [0x1E81], 0x1E82 => [0x1E83],
|
||||
0x1E84 => [0x1E85], 0x1E86 => [0x1E87], 0x1E88 => [0x1E89],
|
||||
0x1E8A => [0x1E8B], 0x1E8C => [0x1E8D], 0x1E8E => [0x1E8F],
|
||||
0x1E90 => [0x1E91], 0x1E92 => [0x1E93], 0x1E94 => [0x1E95],
|
||||
0x1E96 => [0x68, 0x331], 0x1E97 => [0x74, 0x308], 0x1E98 => [0x77, 0x30A],
|
||||
0x1E99 => [0x79, 0x30A], 0x1E9A => [0x61, 0x2BE], 0x1E9B => [0x1E61],
|
||||
0x1EA0 => [0x1EA1], 0x1EA2 => [0x1EA3], 0x1EA4 => [0x1EA5],
|
||||
0x1EA6 => [0x1EA7], 0x1EA8 => [0x1EA9], 0x1EAA => [0x1EAB],
|
||||
0x1EAC => [0x1EAD], 0x1EAE => [0x1EAF], 0x1EB0 => [0x1EB1],
|
||||
0x1EB2 => [0x1EB3], 0x1EB4 => [0x1EB5], 0x1EB6 => [0x1EB7],
|
||||
0x1EB8 => [0x1EB9], 0x1EBA => [0x1EBB], 0x1EBC => [0x1EBD],
|
||||
0x1EBE => [0x1EBF], 0x1EC0 => [0x1EC1], 0x1EC2 => [0x1EC3],
|
||||
0x1EC4 => [0x1EC5], 0x1EC6 => [0x1EC7], 0x1EC8 => [0x1EC9],
|
||||
0x1ECA => [0x1ECB], 0x1ECC => [0x1ECD], 0x1ECE => [0x1ECF],
|
||||
0x1ED0 => [0x1ED1], 0x1ED2 => [0x1ED3], 0x1ED4 => [0x1ED5],
|
||||
0x1ED6 => [0x1ED7], 0x1ED8 => [0x1ED9], 0x1EDA => [0x1EDB],
|
||||
0x1EDC => [0x1EDD], 0x1EDE => [0x1EDF], 0x1EE0 => [0x1EE1],
|
||||
0x1EE2 => [0x1EE3], 0x1EE4 => [0x1EE5], 0x1EE6 => [0x1EE7],
|
||||
0x1EE8 => [0x1EE9], 0x1EEA => [0x1EEB], 0x1EEC => [0x1EED],
|
||||
0x1EEE => [0x1EEF], 0x1EF0 => [0x1EF1], 0x1EF2 => [0x1EF3],
|
||||
0x1EF4 => [0x1EF5], 0x1EF6 => [0x1EF7], 0x1EF8 => [0x1EF9],
|
||||
0x1F08 => [0x1F00], 0x1F09 => [0x1F01], 0x1F0A => [0x1F02],
|
||||
0x1F0B => [0x1F03], 0x1F0C => [0x1F04], 0x1F0D => [0x1F05],
|
||||
0x1F0E => [0x1F06], 0x1F0F => [0x1F07], 0x1F18 => [0x1F10],
|
||||
0x1F19 => [0x1F11], 0x1F1A => [0x1F12], 0x1F1B => [0x1F13],
|
||||
0x1F1C => [0x1F14], 0x1F1D => [0x1F15], 0x1F28 => [0x1F20],
|
||||
0x1F29 => [0x1F21], 0x1F2A => [0x1F22], 0x1F2B => [0x1F23],
|
||||
0x1F2C => [0x1F24], 0x1F2D => [0x1F25], 0x1F2E => [0x1F26],
|
||||
0x1F2F => [0x1F27], 0x1F38 => [0x1F30], 0x1F39 => [0x1F31],
|
||||
0x1F3A => [0x1F32], 0x1F3B => [0x1F33], 0x1F3C => [0x1F34],
|
||||
0x1F3D => [0x1F35], 0x1F3E => [0x1F36], 0x1F3F => [0x1F37],
|
||||
0x1F48 => [0x1F40], 0x1F49 => [0x1F41], 0x1F4A => [0x1F42],
|
||||
0x1F4B => [0x1F43], 0x1F4C => [0x1F44], 0x1F4D => [0x1F45],
|
||||
0x1F50 => [0x3C5, 0x313], 0x1F52 => [0x3C5, 0x313, 0x300],
|
||||
0x1F54 => [0x3C5, 0x313, 0x301], 0x1F56 => [0x3C5, 0x313, 0x342],
|
||||
0x1F59 => [0x1F51], 0x1F5B => [0x1F53], 0x1F5D => [0x1F55],
|
||||
0x1F5F => [0x1F57], 0x1F68 => [0x1F60], 0x1F69 => [0x1F61],
|
||||
0x1F6A => [0x1F62], 0x1F6B => [0x1F63], 0x1F6C => [0x1F64],
|
||||
0x1F6D => [0x1F65], 0x1F6E => [0x1F66], 0x1F6F => [0x1F67],
|
||||
0x1F80 => [0x1F00, 0x3B9], 0x1F81 => [0x1F01, 0x3B9],
|
||||
0x1F82 => [0x1F02, 0x3B9], 0x1F83 => [0x1F03, 0x3B9],
|
||||
0x1F84 => [0x1F04, 0x3B9], 0x1F85 => [0x1F05, 0x3B9],
|
||||
0x1F86 => [0x1F06, 0x3B9], 0x1F87 => [0x1F07, 0x3B9],
|
||||
0x1F88 => [0x1F00, 0x3B9], 0x1F89 => [0x1F01, 0x3B9],
|
||||
0x1F8A => [0x1F02, 0x3B9], 0x1F8B => [0x1F03, 0x3B9],
|
||||
0x1F8C => [0x1F04, 0x3B9], 0x1F8D => [0x1F05, 0x3B9],
|
||||
0x1F8E => [0x1F06, 0x3B9], 0x1F8F => [0x1F07, 0x3B9],
|
||||
0x1F90 => [0x1F20, 0x3B9], 0x1F91 => [0x1F21, 0x3B9],
|
||||
0x1F92 => [0x1F22, 0x3B9], 0x1F93 => [0x1F23, 0x3B9],
|
||||
0x1F94 => [0x1F24, 0x3B9], 0x1F95 => [0x1F25, 0x3B9],
|
||||
0x1F96 => [0x1F26, 0x3B9], 0x1F97 => [0x1F27, 0x3B9],
|
||||
0x1F98 => [0x1F20, 0x3B9], 0x1F99 => [0x1F21, 0x3B9],
|
||||
0x1F9A => [0x1F22, 0x3B9], 0x1F9B => [0x1F23, 0x3B9],
|
||||
0x1F9C => [0x1F24, 0x3B9], 0x1F9D => [0x1F25, 0x3B9],
|
||||
0x1F9E => [0x1F26, 0x3B9], 0x1F9F => [0x1F27, 0x3B9],
|
||||
0x1FA0 => [0x1F60, 0x3B9], 0x1FA1 => [0x1F61, 0x3B9],
|
||||
0x1FA2 => [0x1F62, 0x3B9], 0x1FA3 => [0x1F63, 0x3B9],
|
||||
0x1FA4 => [0x1F64, 0x3B9], 0x1FA5 => [0x1F65, 0x3B9],
|
||||
0x1FA6 => [0x1F66, 0x3B9], 0x1FA7 => [0x1F67, 0x3B9],
|
||||
0x1FA8 => [0x1F60, 0x3B9], 0x1FA9 => [0x1F61, 0x3B9],
|
||||
0x1FAA => [0x1F62, 0x3B9], 0x1FAB => [0x1F63, 0x3B9],
|
||||
0x1FAC => [0x1F64, 0x3B9], 0x1FAD => [0x1F65, 0x3B9],
|
||||
0x1FAE => [0x1F66, 0x3B9], 0x1FAF => [0x1F67, 0x3B9],
|
||||
0x1FB2 => [0x1F70, 0x3B9], 0x1FB3 => [0x3B1, 0x3B9],
|
||||
0x1FB4 => [0x3AC, 0x3B9], 0x1FB6 => [0x3B1, 0x342],
|
||||
0x1FB7 => [0x3B1, 0x342, 0x3B9], 0x1FB8 => [0x1FB0],
|
||||
0x1FB9 => [0x1FB1], 0x1FBA => [0x1F70], 0x1FBB => [0x1F71],
|
||||
0x1FBC => [0x3B1, 0x3B9], 0x1FBE => [0x3B9],
|
||||
0x1FC2 => [0x1F74, 0x3B9], 0x1FC3 => [0x3B7, 0x3B9],
|
||||
0x1FC4 => [0x3AE, 0x3B9], 0x1FC6 => [0x3B7, 0x342],
|
||||
0x1FC7 => [0x3B7, 0x342, 0x3B9], 0x1FC8 => [0x1F72],
|
||||
0x1FC9 => [0x1F73], 0x1FCA => [0x1F74], 0x1FCB => [0x1F75],
|
||||
0x1FCC => [0x3B7, 0x3B9], 0x1FD2 => [0x3B9, 0x308, 0x300],
|
||||
0x1FD3 => [0x3B9, 0x308, 0x301], 0x1FD6 => [0x3B9, 0x342],
|
||||
0x1FD7 => [0x3B9, 0x308, 0x342], 0x1FD8 => [0x1FD0],
|
||||
0x1FD9 => [0x1FD1], 0x1FDA => [0x1F76],
|
||||
0x1FDB => [0x1F77], 0x1FE2 => [0x3C5, 0x308, 0x300],
|
||||
0x1FE3 => [0x3C5, 0x308, 0x301], 0x1FE4 => [0x3C1, 0x313],
|
||||
0x1FE6 => [0x3C5, 0x342], 0x1FE7 => [0x3C5, 0x308, 0x342],
|
||||
0x1FE8 => [0x1FE0], 0x1FE9 => [0x1FE1],
|
||||
0x1FEA => [0x1F7A], 0x1FEB => [0x1F7B],
|
||||
0x1FEC => [0x1FE5], 0x1FF2 => [0x1F7C, 0x3B9],
|
||||
0x1FF3 => [0x3C9, 0x3B9], 0x1FF4 => [0x3CE, 0x3B9],
|
||||
0x1FF6 => [0x3C9, 0x342], 0x1FF7 => [0x3C9, 0x342, 0x3B9],
|
||||
0x1FF8 => [0x1F78], 0x1FF9 => [0x1F79], 0x1FFA => [0x1F7C],
|
||||
0x1FFB => [0x1F7D], 0x1FFC => [0x3C9, 0x3B9],
|
||||
0x20A8 => [0x72, 0x73], 0x2102 => [0x63], 0x2103 => [0xB0, 0x63],
|
||||
0x2107 => [0x25B], 0x2109 => [0xB0, 0x66], 0x210B => [0x68],
|
||||
0x210C => [0x68], 0x210D => [0x68], 0x2110 => [0x69],
|
||||
0x2111 => [0x69], 0x2112 => [0x6C], 0x2115 => [0x6E],
|
||||
0x2116 => [0x6E, 0x6F], 0x2119 => [0x70], 0x211A => [0x71],
|
||||
0x211B => [0x72], 0x211C => [0x72], 0x211D => [0x72],
|
||||
0x2120 => [0x73, 0x6D], 0x2121 => [0x74, 0x65, 0x6C],
|
||||
0x2122 => [0x74, 0x6D], 0x2124 => [0x7A], 0x2126 => [0x3C9],
|
||||
0x2128 => [0x7A], 0x212A => [0x6B], 0x212B => [0xE5],
|
||||
0x212C => [0x62], 0x212D => [0x63], 0x2130 => [0x65],
|
||||
0x2131 => [0x66], 0x2133 => [0x6D], 0x213E => [0x3B3],
|
||||
0x213F => [0x3C0], 0x2145 => [0x64], 0x2160 => [0x2170],
|
||||
0x2161 => [0x2171], 0x2162 => [0x2172], 0x2163 => [0x2173],
|
||||
0x2164 => [0x2174], 0x2165 => [0x2175], 0x2166 => [0x2176],
|
||||
0x2167 => [0x2177], 0x2168 => [0x2178], 0x2169 => [0x2179],
|
||||
0x216A => [0x217A], 0x216B => [0x217B], 0x216C => [0x217C],
|
||||
0x216D => [0x217D], 0x216E => [0x217E], 0x216F => [0x217F],
|
||||
0x24B6 => [0x24D0], 0x24B7 => [0x24D1], 0x24B8 => [0x24D2],
|
||||
0x24B9 => [0x24D3], 0x24BA => [0x24D4], 0x24BB => [0x24D5],
|
||||
0x24BC => [0x24D6], 0x24BD => [0x24D7], 0x24BE => [0x24D8],
|
||||
0x24BF => [0x24D9], 0x24C0 => [0x24DA], 0x24C1 => [0x24DB],
|
||||
0x24C2 => [0x24DC], 0x24C3 => [0x24DD], 0x24C4 => [0x24DE],
|
||||
0x24C5 => [0x24DF], 0x24C6 => [0x24E0], 0x24C7 => [0x24E1],
|
||||
0x24C8 => [0x24E2], 0x24C9 => [0x24E3], 0x24CA => [0x24E4],
|
||||
0x24CB => [0x24E5], 0x24CC => [0x24E6], 0x24CD => [0x24E7],
|
||||
0x24CE => [0x24E8], 0x24CF => [0x24E9], 0x3371 => [0x68, 0x70, 0x61],
|
||||
0x3373 => [0x61, 0x75], 0x3375 => [0x6F, 0x76],
|
||||
0x3380 => [0x70, 0x61], 0x3381 => [0x6E, 0x61],
|
||||
0x3382 => [0x3BC, 0x61], 0x3383 => [0x6D, 0x61],
|
||||
0x3384 => [0x6B, 0x61], 0x3385 => [0x6B, 0x62],
|
||||
0x3386 => [0x6D, 0x62], 0x3387 => [0x67, 0x62],
|
||||
0x338A => [0x70, 0x66], 0x338B => [0x6E, 0x66],
|
||||
0x338C => [0x3BC, 0x66], 0x3390 => [0x68, 0x7A],
|
||||
0x3391 => [0x6B, 0x68, 0x7A], 0x3392 => [0x6D, 0x68, 0x7A],
|
||||
0x3393 => [0x67, 0x68, 0x7A], 0x3394 => [0x74, 0x68, 0x7A],
|
||||
0x33A9 => [0x70, 0x61], 0x33AA => [0x6B, 0x70, 0x61],
|
||||
0x33AB => [0x6D, 0x70, 0x61], 0x33AC => [0x67, 0x70, 0x61],
|
||||
0x33B4 => [0x70, 0x76], 0x33B5 => [0x6E, 0x76],
|
||||
0x33B6 => [0x3BC, 0x76], 0x33B7 => [0x6D, 0x76],
|
||||
0x33B8 => [0x6B, 0x76], 0x33B9 => [0x6D, 0x76],
|
||||
0x33BA => [0x70, 0x77], 0x33BB => [0x6E, 0x77],
|
||||
0x33BC => [0x3BC, 0x77], 0x33BD => [0x6D, 0x77],
|
||||
0x33BE => [0x6B, 0x77], 0x33BF => [0x6D, 0x77],
|
||||
0x33C0 => [0x6B, 0x3C9], 0x33C1 => [0x6D, 0x3C9], /*
|
||||
0x33C2 => array(0x61, 0x2E, 0x6D, 0x2E), */
|
||||
0x33C3 => [0x62, 0x71], 0x33C6 => [0x63, 0x2215, 0x6B, 0x67],
|
||||
0x33C7 => [0x63, 0x6F, 0x2E], 0x33C8 => [0x64, 0x62],
|
||||
0x33C9 => [0x67, 0x79], 0x33CB => [0x68, 0x70],
|
||||
0x33CD => [0x6B, 0x6B], 0x33CE => [0x6B, 0x6D],
|
||||
0x33D7 => [0x70, 0x68], 0x33D9 => [0x70, 0x70, 0x6D],
|
||||
0x33DA => [0x70, 0x72], 0x33DC => [0x73, 0x76],
|
||||
0x33DD => [0x77, 0x62], 0xFB00 => [0x66, 0x66],
|
||||
0xFB01 => [0x66, 0x69], 0xFB02 => [0x66, 0x6C],
|
||||
0xFB03 => [0x66, 0x66, 0x69], 0xFB04 => [0x66, 0x66, 0x6C],
|
||||
0xFB05 => [0x73, 0x74], 0xFB06 => [0x73, 0x74],
|
||||
0xFB13 => [0x574, 0x576], 0xFB14 => [0x574, 0x565],
|
||||
0xFB15 => [0x574, 0x56B], 0xFB16 => [0x57E, 0x576],
|
||||
0xFB17 => [0x574, 0x56D], 0xFF21 => [0xFF41],
|
||||
0xFF22 => [0xFF42], 0xFF23 => [0xFF43], 0xFF24 => [0xFF44],
|
||||
0xFF25 => [0xFF45], 0xFF26 => [0xFF46], 0xFF27 => [0xFF47],
|
||||
0xFF28 => [0xFF48], 0xFF29 => [0xFF49], 0xFF2A => [0xFF4A],
|
||||
0xFF2B => [0xFF4B], 0xFF2C => [0xFF4C], 0xFF2D => [0xFF4D],
|
||||
0xFF2E => [0xFF4E], 0xFF2F => [0xFF4F], 0xFF30 => [0xFF50],
|
||||
0xFF31 => [0xFF51], 0xFF32 => [0xFF52], 0xFF33 => [0xFF53],
|
||||
0xFF34 => [0xFF54], 0xFF35 => [0xFF55], 0xFF36 => [0xFF56],
|
||||
0xFF37 => [0xFF57], 0xFF38 => [0xFF58], 0xFF39 => [0xFF59],
|
||||
0xFF3A => [0xFF5A], 0x10400 => [0x10428], 0x10401 => [0x10429],
|
||||
0x10402 => [0x1042A], 0x10403 => [0x1042B], 0x10404 => [0x1042C],
|
||||
0x10405 => [0x1042D], 0x10406 => [0x1042E], 0x10407 => [0x1042F],
|
||||
0x10408 => [0x10430], 0x10409 => [0x10431], 0x1040A => [0x10432],
|
||||
0x1040B => [0x10433], 0x1040C => [0x10434], 0x1040D => [0x10435],
|
||||
0x1040E => [0x10436], 0x1040F => [0x10437], 0x10410 => [0x10438],
|
||||
0x10411 => [0x10439], 0x10412 => [0x1043A], 0x10413 => [0x1043B],
|
||||
0x10414 => [0x1043C], 0x10415 => [0x1043D], 0x10416 => [0x1043E],
|
||||
0x10417 => [0x1043F], 0x10418 => [0x10440], 0x10419 => [0x10441],
|
||||
0x1041A => [0x10442], 0x1041B => [0x10443], 0x1041C => [0x10444],
|
||||
0x1041D => [0x10445], 0x1041E => [0x10446], 0x1041F => [0x10447],
|
||||
0x10420 => [0x10448], 0x10421 => [0x10449], 0x10422 => [0x1044A],
|
||||
0x10423 => [0x1044B], 0x10424 => [0x1044C], 0x10425 => [0x1044D],
|
||||
0x1D400 => [0x61], 0x1D401 => [0x62], 0x1D402 => [0x63],
|
||||
0x1D403 => [0x64], 0x1D404 => [0x65], 0x1D405 => [0x66],
|
||||
0x1D406 => [0x67], 0x1D407 => [0x68], 0x1D408 => [0x69],
|
||||
0x1D409 => [0x6A], 0x1D40A => [0x6B], 0x1D40B => [0x6C],
|
||||
0x1D40C => [0x6D], 0x1D40D => [0x6E], 0x1D40E => [0x6F],
|
||||
0x1D40F => [0x70], 0x1D410 => [0x71], 0x1D411 => [0x72],
|
||||
0x1D412 => [0x73], 0x1D413 => [0x74], 0x1D414 => [0x75],
|
||||
0x1D415 => [0x76], 0x1D416 => [0x77], 0x1D417 => [0x78],
|
||||
0x1D418 => [0x79], 0x1D419 => [0x7A], 0x1D434 => [0x61],
|
||||
0x1D435 => [0x62], 0x1D436 => [0x63], 0x1D437 => [0x64],
|
||||
0x1D438 => [0x65], 0x1D439 => [0x66], 0x1D43A => [0x67],
|
||||
0x1D43B => [0x68], 0x1D43C => [0x69], 0x1D43D => [0x6A],
|
||||
0x1D43E => [0x6B], 0x1D43F => [0x6C], 0x1D440 => [0x6D],
|
||||
0x1D441 => [0x6E], 0x1D442 => [0x6F], 0x1D443 => [0x70],
|
||||
0x1D444 => [0x71], 0x1D445 => [0x72], 0x1D446 => [0x73],
|
||||
0x1D447 => [0x74], 0x1D448 => [0x75], 0x1D449 => [0x76],
|
||||
0x1D44A => [0x77], 0x1D44B => [0x78], 0x1D44C => [0x79],
|
||||
0x1D44D => [0x7A], 0x1D468 => [0x61], 0x1D469 => [0x62],
|
||||
0x1D46A => [0x63], 0x1D46B => [0x64], 0x1D46C => [0x65],
|
||||
0x1D46D => [0x66], 0x1D46E => [0x67], 0x1D46F => [0x68],
|
||||
0x1D470 => [0x69], 0x1D471 => [0x6A], 0x1D472 => [0x6B],
|
||||
0x1D473 => [0x6C], 0x1D474 => [0x6D], 0x1D475 => [0x6E],
|
||||
0x1D476 => [0x6F], 0x1D477 => [0x70], 0x1D478 => [0x71],
|
||||
0x1D479 => [0x72], 0x1D47A => [0x73], 0x1D47B => [0x74],
|
||||
0x1D47C => [0x75], 0x1D47D => [0x76], 0x1D47E => [0x77],
|
||||
0x1D47F => [0x78], 0x1D480 => [0x79], 0x1D481 => [0x7A],
|
||||
0x1D49C => [0x61], 0x1D49E => [0x63], 0x1D49F => [0x64],
|
||||
0x1D4A2 => [0x67], 0x1D4A5 => [0x6A], 0x1D4A6 => [0x6B],
|
||||
0x1D4A9 => [0x6E], 0x1D4AA => [0x6F], 0x1D4AB => [0x70],
|
||||
0x1D4AC => [0x71], 0x1D4AE => [0x73], 0x1D4AF => [0x74],
|
||||
0x1D4B0 => [0x75], 0x1D4B1 => [0x76], 0x1D4B2 => [0x77],
|
||||
0x1D4B3 => [0x78], 0x1D4B4 => [0x79], 0x1D4B5 => [0x7A],
|
||||
0x1D4D0 => [0x61], 0x1D4D1 => [0x62], 0x1D4D2 => [0x63],
|
||||
0x1D4D3 => [0x64], 0x1D4D4 => [0x65], 0x1D4D5 => [0x66],
|
||||
0x1D4D6 => [0x67], 0x1D4D7 => [0x68], 0x1D4D8 => [0x69],
|
||||
0x1D4D9 => [0x6A], 0x1D4DA => [0x6B], 0x1D4DB => [0x6C],
|
||||
0x1D4DC => [0x6D], 0x1D4DD => [0x6E], 0x1D4DE => [0x6F],
|
||||
0x1D4DF => [0x70], 0x1D4E0 => [0x71], 0x1D4E1 => [0x72],
|
||||
0x1D4E2 => [0x73], 0x1D4E3 => [0x74], 0x1D4E4 => [0x75],
|
||||
0x1D4E5 => [0x76], 0x1D4E6 => [0x77], 0x1D4E7 => [0x78],
|
||||
0x1D4E8 => [0x79], 0x1D4E9 => [0x7A], 0x1D504 => [0x61],
|
||||
0x1D505 => [0x62], 0x1D507 => [0x64], 0x1D508 => [0x65],
|
||||
0x1D509 => [0x66], 0x1D50A => [0x67], 0x1D50D => [0x6A],
|
||||
0x1D50E => [0x6B], 0x1D50F => [0x6C], 0x1D510 => [0x6D],
|
||||
0x1D511 => [0x6E], 0x1D512 => [0x6F], 0x1D513 => [0x70],
|
||||
0x1D514 => [0x71], 0x1D516 => [0x73], 0x1D517 => [0x74],
|
||||
0x1D518 => [0x75], 0x1D519 => [0x76], 0x1D51A => [0x77],
|
||||
0x1D51B => [0x78], 0x1D51C => [0x79], 0x1D538 => [0x61],
|
||||
0x1D539 => [0x62], 0x1D53B => [0x64], 0x1D53C => [0x65],
|
||||
0x1D53D => [0x66], 0x1D53E => [0x67], 0x1D540 => [0x69],
|
||||
0x1D541 => [0x6A], 0x1D542 => [0x6B], 0x1D543 => [0x6C],
|
||||
0x1D544 => [0x6D], 0x1D546 => [0x6F], 0x1D54A => [0x73],
|
||||
0x1D54B => [0x74], 0x1D54C => [0x75], 0x1D54D => [0x76],
|
||||
0x1D54E => [0x77], 0x1D54F => [0x78], 0x1D550 => [0x79],
|
||||
0x1D56C => [0x61], 0x1D56D => [0x62], 0x1D56E => [0x63],
|
||||
0x1D56F => [0x64], 0x1D570 => [0x65], 0x1D571 => [0x66],
|
||||
0x1D572 => [0x67], 0x1D573 => [0x68], 0x1D574 => [0x69],
|
||||
0x1D575 => [0x6A], 0x1D576 => [0x6B], 0x1D577 => [0x6C],
|
||||
0x1D578 => [0x6D], 0x1D579 => [0x6E], 0x1D57A => [0x6F],
|
||||
0x1D57B => [0x70], 0x1D57C => [0x71], 0x1D57D => [0x72],
|
||||
0x1D57E => [0x73], 0x1D57F => [0x74], 0x1D580 => [0x75],
|
||||
0x1D581 => [0x76], 0x1D582 => [0x77], 0x1D583 => [0x78],
|
||||
0x1D584 => [0x79], 0x1D585 => [0x7A], 0x1D5A0 => [0x61],
|
||||
0x1D5A1 => [0x62], 0x1D5A2 => [0x63], 0x1D5A3 => [0x64],
|
||||
0x1D5A4 => [0x65], 0x1D5A5 => [0x66], 0x1D5A6 => [0x67],
|
||||
0x1D5A7 => [0x68], 0x1D5A8 => [0x69], 0x1D5A9 => [0x6A],
|
||||
0x1D5AA => [0x6B], 0x1D5AB => [0x6C], 0x1D5AC => [0x6D],
|
||||
0x1D5AD => [0x6E], 0x1D5AE => [0x6F], 0x1D5AF => [0x70],
|
||||
0x1D5B0 => [0x71], 0x1D5B1 => [0x72], 0x1D5B2 => [0x73],
|
||||
0x1D5B3 => [0x74], 0x1D5B4 => [0x75], 0x1D5B5 => [0x76],
|
||||
0x1D5B6 => [0x77], 0x1D5B7 => [0x78], 0x1D5B8 => [0x79],
|
||||
0x1D5B9 => [0x7A], 0x1D5D4 => [0x61], 0x1D5D5 => [0x62],
|
||||
0x1D5D6 => [0x63], 0x1D5D7 => [0x64], 0x1D5D8 => [0x65],
|
||||
0x1D5D9 => [0x66], 0x1D5DA => [0x67], 0x1D5DB => [0x68],
|
||||
0x1D5DC => [0x69], 0x1D5DD => [0x6A], 0x1D5DE => [0x6B],
|
||||
0x1D5DF => [0x6C], 0x1D5E0 => [0x6D], 0x1D5E1 => [0x6E],
|
||||
0x1D5E2 => [0x6F], 0x1D5E3 => [0x70], 0x1D5E4 => [0x71],
|
||||
0x1D5E5 => [0x72], 0x1D5E6 => [0x73], 0x1D5E7 => [0x74],
|
||||
0x1D5E8 => [0x75], 0x1D5E9 => [0x76], 0x1D5EA => [0x77],
|
||||
0x1D5EB => [0x78], 0x1D5EC => [0x79], 0x1D5ED => [0x7A],
|
||||
0x1D608 => [0x61], 0x1D609 => [0x62], 0x1D60A => [0x63],
|
||||
0x1D60B => [0x64], 0x1D60C => [0x65], 0x1D60D => [0x66],
|
||||
0x1D60E => [0x67], 0x1D60F => [0x68], 0x1D610 => [0x69],
|
||||
0x1D611 => [0x6A], 0x1D612 => [0x6B], 0x1D613 => [0x6C],
|
||||
0x1D614 => [0x6D], 0x1D615 => [0x6E], 0x1D616 => [0x6F],
|
||||
0x1D617 => [0x70], 0x1D618 => [0x71], 0x1D619 => [0x72],
|
||||
0x1D61A => [0x73], 0x1D61B => [0x74], 0x1D61C => [0x75],
|
||||
0x1D61D => [0x76], 0x1D61E => [0x77], 0x1D61F => [0x78],
|
||||
0x1D620 => [0x79], 0x1D621 => [0x7A], 0x1D63C => [0x61],
|
||||
0x1D63D => [0x62], 0x1D63E => [0x63], 0x1D63F => [0x64],
|
||||
0x1D640 => [0x65], 0x1D641 => [0x66], 0x1D642 => [0x67],
|
||||
0x1D643 => [0x68], 0x1D644 => [0x69], 0x1D645 => [0x6A],
|
||||
0x1D646 => [0x6B], 0x1D647 => [0x6C], 0x1D648 => [0x6D],
|
||||
0x1D649 => [0x6E], 0x1D64A => [0x6F], 0x1D64B => [0x70],
|
||||
0x1D64C => [0x71], 0x1D64D => [0x72], 0x1D64E => [0x73],
|
||||
0x1D64F => [0x74], 0x1D650 => [0x75], 0x1D651 => [0x76],
|
||||
0x1D652 => [0x77], 0x1D653 => [0x78], 0x1D654 => [0x79],
|
||||
0x1D655 => [0x7A], 0x1D670 => [0x61], 0x1D671 => [0x62],
|
||||
0x1D672 => [0x63], 0x1D673 => [0x64], 0x1D674 => [0x65],
|
||||
0x1D675 => [0x66], 0x1D676 => [0x67], 0x1D677 => [0x68],
|
||||
0x1D678 => [0x69], 0x1D679 => [0x6A], 0x1D67A => [0x6B],
|
||||
0x1D67B => [0x6C], 0x1D67C => [0x6D], 0x1D67D => [0x6E],
|
||||
0x1D67E => [0x6F], 0x1D67F => [0x70], 0x1D680 => [0x71],
|
||||
0x1D681 => [0x72], 0x1D682 => [0x73], 0x1D683 => [0x74],
|
||||
0x1D684 => [0x75], 0x1D685 => [0x76], 0x1D686 => [0x77],
|
||||
0x1D687 => [0x78], 0x1D688 => [0x79], 0x1D689 => [0x7A],
|
||||
0x1D6A8 => [0x3B1], 0x1D6A9 => [0x3B2], 0x1D6AA => [0x3B3],
|
||||
0x1D6AB => [0x3B4], 0x1D6AC => [0x3B5], 0x1D6AD => [0x3B6],
|
||||
0x1D6AE => [0x3B7], 0x1D6AF => [0x3B8], 0x1D6B0 => [0x3B9],
|
||||
0x1D6B1 => [0x3BA], 0x1D6B2 => [0x3BB], 0x1D6B3 => [0x3BC],
|
||||
0x1D6B4 => [0x3BD], 0x1D6B5 => [0x3BE], 0x1D6B6 => [0x3BF],
|
||||
0x1D6B7 => [0x3C0], 0x1D6B8 => [0x3C1], 0x1D6B9 => [0x3B8],
|
||||
0x1D6BA => [0x3C3], 0x1D6BB => [0x3C4], 0x1D6BC => [0x3C5],
|
||||
0x1D6BD => [0x3C6], 0x1D6BE => [0x3C7], 0x1D6BF => [0x3C8],
|
||||
0x1D6C0 => [0x3C9], 0x1D6D3 => [0x3C3], 0x1D6E2 => [0x3B1],
|
||||
0x1D6E3 => [0x3B2], 0x1D6E4 => [0x3B3], 0x1D6E5 => [0x3B4],
|
||||
0x1D6E6 => [0x3B5], 0x1D6E7 => [0x3B6], 0x1D6E8 => [0x3B7],
|
||||
0x1D6E9 => [0x3B8], 0x1D6EA => [0x3B9], 0x1D6EB => [0x3BA],
|
||||
0x1D6EC => [0x3BB], 0x1D6ED => [0x3BC], 0x1D6EE => [0x3BD],
|
||||
0x1D6EF => [0x3BE], 0x1D6F0 => [0x3BF], 0x1D6F1 => [0x3C0],
|
||||
0x1D6F2 => [0x3C1], 0x1D6F3 => [0x3B8], 0x1D6F4 => [0x3C3],
|
||||
0x1D6F5 => [0x3C4], 0x1D6F6 => [0x3C5], 0x1D6F7 => [0x3C6],
|
||||
0x1D6F8 => [0x3C7], 0x1D6F9 => [0x3C8], 0x1D6FA => [0x3C9],
|
||||
0x1D70D => [0x3C3], 0x1D71C => [0x3B1], 0x1D71D => [0x3B2],
|
||||
0x1D71E => [0x3B3], 0x1D71F => [0x3B4], 0x1D720 => [0x3B5],
|
||||
0x1D721 => [0x3B6], 0x1D722 => [0x3B7], 0x1D723 => [0x3B8],
|
||||
0x1D724 => [0x3B9], 0x1D725 => [0x3BA], 0x1D726 => [0x3BB],
|
||||
0x1D727 => [0x3BC], 0x1D728 => [0x3BD], 0x1D729 => [0x3BE],
|
||||
0x1D72A => [0x3BF], 0x1D72B => [0x3C0], 0x1D72C => [0x3C1],
|
||||
0x1D72D => [0x3B8], 0x1D72E => [0x3C3], 0x1D72F => [0x3C4],
|
||||
0x1D730 => [0x3C5], 0x1D731 => [0x3C6], 0x1D732 => [0x3C7],
|
||||
0x1D733 => [0x3C8], 0x1D734 => [0x3C9], 0x1D747 => [0x3C3],
|
||||
0x1D756 => [0x3B1], 0x1D757 => [0x3B2], 0x1D758 => [0x3B3],
|
||||
0x1D759 => [0x3B4], 0x1D75A => [0x3B5], 0x1D75B => [0x3B6],
|
||||
0x1D75C => [0x3B7], 0x1D75D => [0x3B8], 0x1D75E => [0x3B9],
|
||||
0x1D75F => [0x3BA], 0x1D760 => [0x3BB], 0x1D761 => [0x3BC],
|
||||
0x1D762 => [0x3BD], 0x1D763 => [0x3BE], 0x1D764 => [0x3BF],
|
||||
0x1D765 => [0x3C0], 0x1D766 => [0x3C1], 0x1D767 => [0x3B8],
|
||||
0x1D768 => [0x3C3], 0x1D769 => [0x3C4], 0x1D76A => [0x3C5],
|
||||
0x1D76B => [0x3C6], 0x1D76C => [0x3C7], 0x1D76D => [0x3C8],
|
||||
0x1D76E => [0x3C9], 0x1D781 => [0x3C3], 0x1D790 => [0x3B1],
|
||||
0x1D791 => [0x3B2], 0x1D792 => [0x3B3], 0x1D793 => [0x3B4],
|
||||
0x1D794 => [0x3B5], 0x1D795 => [0x3B6], 0x1D796 => [0x3B7],
|
||||
0x1D797 => [0x3B8], 0x1D798 => [0x3B9], 0x1D799 => [0x3BA],
|
||||
0x1D79A => [0x3BB], 0x1D79B => [0x3BC], 0x1D79C => [0x3BD],
|
||||
0x1D79D => [0x3BE], 0x1D79E => [0x3BF], 0x1D79F => [0x3C0],
|
||||
0x1D7A0 => [0x3C1], 0x1D7A1 => [0x3B8], 0x1D7A2 => [0x3C3],
|
||||
0x1D7A3 => [0x3C4], 0x1D7A4 => [0x3C5], 0x1D7A5 => [0x3C6],
|
||||
0x1D7A6 => [0x3C7], 0x1D7A7 => [0x3C8], 0x1D7A8 => [0x3C9],
|
||||
0x1D7BB => [0x3C3], 0x3F9 => [0x3C3], 0x1D2C => [0x61],
|
||||
0x1D2D => [0xE6], 0x1D2E => [0x62], 0x1D30 => [0x64],
|
||||
0x1D31 => [0x65], 0x1D32 => [0x1DD], 0x1D33 => [0x67],
|
||||
0x1D34 => [0x68], 0x1D35 => [0x69], 0x1D36 => [0x6A],
|
||||
0x1D37 => [0x6B], 0x1D38 => [0x6C], 0x1D39 => [0x6D],
|
||||
0x1D3A => [0x6E], 0x1D3C => [0x6F], 0x1D3D => [0x223],
|
||||
0x1D3E => [0x70], 0x1D3F => [0x72], 0x1D40 => [0x74],
|
||||
0x1D41 => [0x75], 0x1D42 => [0x77], 0x213B => [0x66, 0x61, 0x78],
|
||||
0x3250 => [0x70, 0x74, 0x65], 0x32CC => [0x68, 0x67],
|
||||
0x32CE => [0x65, 0x76], 0x32CF => [0x6C, 0x74, 0x64],
|
||||
0x337A => [0x69, 0x75], 0x33DE => [0x76, 0x2215, 0x6D],
|
||||
0x33DF => [0x61, 0x2215, 0x6D]
|
||||
];
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Mso\IdnaConvert;
|
||||
|
||||
interface NamePrepDataInterface
|
||||
{
|
||||
}
|
||||
@@ -1,555 +0,0 @@
|
||||
<?php
|
||||
|
||||
// {{{ license
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This library is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU Lesser General Public License as |
|
||||
// | published by the Free Software Foundation; either version 2.1 of the |
|
||||
// | License, or (at your option) any later version. |
|
||||
// | |
|
||||
// | This library is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | Lesser General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU Lesser General Public |
|
||||
// | License along with this library; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 51 Franklin St, Boston, MA 02110, United States |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// }}}
|
||||
|
||||
/*
|
||||
* @author Matthias Sommerfeld <mso@phlylabs.de>
|
||||
* @copyright 2004-2016 phlyLabs Berlin, http://phlylabs.de
|
||||
* @version 1.0.1 2016-01-24
|
||||
*/
|
||||
|
||||
namespace Mso\IdnaConvert;
|
||||
|
||||
class Punycode implements PunycodeInterface
|
||||
{
|
||||
// Internal settings, do not touch!
|
||||
const punycodePrefix = 'xn--';
|
||||
const invalidUcs = 0x80000000;
|
||||
const maxUcs = 0x10FFFF;
|
||||
const base = 36;
|
||||
const tMin = 1;
|
||||
const tMax = 26;
|
||||
const skew = 38;
|
||||
const damp = 700;
|
||||
const initialBias = 72;
|
||||
const initialN = 0x80;
|
||||
const sBase = 0xAC00;
|
||||
const lBase = 0x1100;
|
||||
const vBase = 0x1161;
|
||||
const tBase = 0x11A7;
|
||||
const lCount = 19;
|
||||
const vCount = 21;
|
||||
const tCount = 28;
|
||||
const nCount = 588; // vCount * tCount
|
||||
const sCount = 11172; // lCount * tCount * vCount
|
||||
const sLast = self::sBase + self::lCount * self::vCount * self::tCount;
|
||||
|
||||
protected static $isMbStringOverload = null;
|
||||
|
||||
protected $NamePrepData;
|
||||
protected $UnicodeTranscoder;
|
||||
|
||||
/**
|
||||
* the constructor
|
||||
*
|
||||
* @param $NamePrepData NamePrepDataInterface inject NamePrepData object
|
||||
* @param $UnicodeTranscoder UnicodeTranscoderInterface inject Unicode Transcoder
|
||||
* @since 0.5.2
|
||||
*/
|
||||
public function __construct(NamePrepDataInterface $NamePrepData, UnicodeTranscoderInterface $UnicodeTranscoder)
|
||||
{
|
||||
// populate mbstring overloading cache if not set
|
||||
if (self::$isMbStringOverload === null) {
|
||||
self::$isMbStringOverload = (extension_loaded('mbstring') && (ini_get('mbstring.func_overload') & 0x02) === 0x02);
|
||||
}
|
||||
|
||||
$this->NamePrepData = $NamePrepData;
|
||||
$this->UnicodeTranscoder = $UnicodeTranscoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the used prefix for punycode-encoded strings
|
||||
* @return string
|
||||
*/
|
||||
public function getPunycodePrefix()
|
||||
{
|
||||
return self::punycodePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, whether or not the provided string is a valid punycode string
|
||||
* @param string $encoded
|
||||
* @return boolean
|
||||
*/
|
||||
public function validate($encoded) {
|
||||
// Check for existence of the prefix
|
||||
if (strpos($encoded, self::punycodePrefix) !== 0) {
|
||||
return false;
|
||||
}
|
||||
// If nothing is left after the prefix, it is hopeless
|
||||
if (strlen(trim($encoded)) <= strlen(self::punycodePrefix)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual decoding algorithm
|
||||
* @param string
|
||||
* @return mixed
|
||||
*/
|
||||
public function decode($encoded)
|
||||
{
|
||||
if (!$this->validate($encoded)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$decoded = [];
|
||||
// Find last occurence of the delimiter
|
||||
$delim_pos = strrpos($encoded, '-');
|
||||
if ($delim_pos > self::byteLength(self::punycodePrefix)) {
|
||||
for ($k = self::byteLength(self::punycodePrefix); $k < $delim_pos; ++$k) {
|
||||
$decoded[] = ord($encoded{$k});
|
||||
}
|
||||
}
|
||||
$deco_len = count($decoded);
|
||||
$enco_len = self::byteLength($encoded);
|
||||
|
||||
// Wandering through the strings; init
|
||||
$is_first = true;
|
||||
$bias = self::initialBias;
|
||||
$idx = 0;
|
||||
$char = self::initialN;
|
||||
|
||||
for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
|
||||
for ($old_idx = $idx, $w = 1, $k = self::base; 1; $k += self::base) {
|
||||
$digit = $this->decodeDigit($encoded{$enco_idx++});
|
||||
$idx += $digit * $w;
|
||||
$t = ($k <= $bias) ? self::tMin :
|
||||
(($k >= $bias + self::tMax) ? self::tMax : ($k - $bias));
|
||||
if ($digit < $t) {
|
||||
break;
|
||||
}
|
||||
$w = (int) ($w * (self::base - $t));
|
||||
}
|
||||
$bias = $this->adapt($idx - $old_idx, $deco_len + 1, $is_first);
|
||||
$is_first = false;
|
||||
$char += (int) ($idx / ($deco_len + 1));
|
||||
$idx %= ($deco_len + 1);
|
||||
if ($deco_len > 0) {
|
||||
// Make room for the decoded char
|
||||
for ($i = $deco_len; $i > $idx; $i--) {
|
||||
$decoded[$i] = $decoded[($i - 1)];
|
||||
}
|
||||
}
|
||||
$decoded[$idx++] = $char;
|
||||
}
|
||||
return $this->UnicodeTranscoder->ucs4array_utf8($decoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual encoding algorithm
|
||||
* @param array $decoded
|
||||
* @return mixed
|
||||
*/
|
||||
public function encode($decoded)
|
||||
{
|
||||
// We cannot encode a domain name containing the Punycode prefix
|
||||
$extract = self::byteLength(self::punycodePrefix);
|
||||
$check_pref = $this->UnicodeTranscoder->utf8_ucs4array(self::punycodePrefix);
|
||||
$check_deco = array_slice($decoded, 0, $extract);
|
||||
|
||||
if ($check_pref == $check_deco) {
|
||||
throw new \InvalidArgumentException('This is already a Punycode string');
|
||||
}
|
||||
// We will not try to encode strings consisting of basic code points only
|
||||
$encodable = false;
|
||||
foreach ($decoded as $k => $v) {
|
||||
if ($v > 0x7a) {
|
||||
$encodable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$encodable) {
|
||||
return false;
|
||||
}
|
||||
// Do NAMEPREP
|
||||
$decoded = $this->namePrep($decoded);
|
||||
if (!$decoded || !is_array($decoded)) {
|
||||
return false; // NAMEPREP failed
|
||||
}
|
||||
$deco_len = count($decoded);
|
||||
if (!$deco_len) {
|
||||
return false; // Empty array
|
||||
}
|
||||
$codecount = 0; // How many chars have been consumed
|
||||
$encoded = '';
|
||||
// Copy all basic code points to output
|
||||
for ($i = 0; $i < $deco_len; ++$i) {
|
||||
$test = $decoded[$i];
|
||||
// Will match [-0-9a-zA-Z]
|
||||
if ((0x2F < $test && $test < 0x40)
|
||||
|| (0x40 < $test && $test < 0x5B)
|
||||
|| (0x60 < $test && $test <= 0x7B)
|
||||
|| (0x2D == $test)) {
|
||||
$encoded .= chr($decoded[$i]);
|
||||
$codecount++;
|
||||
}
|
||||
}
|
||||
if ($codecount == $deco_len) {
|
||||
return $encoded; // All codepoints were basic ones
|
||||
}
|
||||
// Start with the prefix; copy it to output
|
||||
$encoded = self::punycodePrefix . $encoded;
|
||||
// If we have basic code points in output, add an hyphen to the end
|
||||
if ($codecount) {
|
||||
$encoded .= '-';
|
||||
}
|
||||
// Now find and encode all non-basic code points
|
||||
$is_first = true;
|
||||
$cur_code = self::initialN;
|
||||
$bias = self::initialBias;
|
||||
$delta = 0;
|
||||
while ($codecount < $deco_len) {
|
||||
// Find the smallest code point >= the current code point and
|
||||
// remember the last ouccrence of it in the input
|
||||
for ($i = 0, $next_code = self::maxUcs; $i < $deco_len; $i++) {
|
||||
if ($decoded[$i] >= $cur_code && $decoded[$i] <= $next_code) {
|
||||
$next_code = $decoded[$i];
|
||||
}
|
||||
}
|
||||
$delta += ($next_code - $cur_code) * ($codecount + 1);
|
||||
$cur_code = $next_code;
|
||||
|
||||
// Scan input again and encode all characters whose code point is $cur_code
|
||||
for ($i = 0; $i < $deco_len; $i++) {
|
||||
if ($decoded[$i] < $cur_code) {
|
||||
$delta++;
|
||||
} elseif ($decoded[$i] == $cur_code) {
|
||||
for ($q = $delta, $k = self::base; 1; $k += self::base) {
|
||||
$t = ($k <= $bias)
|
||||
? self::tMin
|
||||
: (($k >= $bias + self::tMax) ? self::tMax : $k - $bias);
|
||||
if ($q < $t) {
|
||||
break;
|
||||
}
|
||||
|
||||
$encoded .= $this->encodeDigit(intval($t + (($q - $t) % (self::base - $t))));
|
||||
$q = (int) (($q - $t) / (self::base - $t));
|
||||
}
|
||||
$encoded .= $this->encodeDigit($q);
|
||||
$bias = $this->adapt($delta, $codecount + 1, $is_first);
|
||||
$codecount++;
|
||||
$delta = 0;
|
||||
$is_first = false;
|
||||
}
|
||||
}
|
||||
$delta++;
|
||||
$cur_code++;
|
||||
}
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt the bias according to the current code point and position
|
||||
* @param int $delta
|
||||
* @param int $npoints
|
||||
* @param int $is_first
|
||||
* @return int
|
||||
*/
|
||||
protected function adapt($delta, $npoints, $is_first)
|
||||
{
|
||||
$delta = intval($is_first ? ($delta / self::damp) : ($delta / 2));
|
||||
$delta += intval($delta / $npoints);
|
||||
for ($k = 0; $delta > ((self::base - self::tMin) * self::tMax) / 2; $k += self::base) {
|
||||
$delta = intval($delta / (self::base - self::tMin));
|
||||
}
|
||||
return intval($k + (self::base - self::tMin + 1) * $delta / ($delta + self::skew));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encoding a certain digit
|
||||
* @param int $d
|
||||
* @return string
|
||||
*/
|
||||
protected function encodeDigit($d)
|
||||
{
|
||||
return chr($d + 22 + 75 * ($d < 26));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a certain digit
|
||||
* @param int $cp
|
||||
* @return int
|
||||
*/
|
||||
protected function decodeDigit($cp)
|
||||
{
|
||||
$cp = ord($cp);
|
||||
if ($cp - 48 < 10) {
|
||||
|
||||
return $cp - 22;
|
||||
}
|
||||
|
||||
if ($cp - 65 < 26) {
|
||||
|
||||
return $cp - 65;
|
||||
}
|
||||
if ($cp - 97 < 26) {
|
||||
|
||||
return $cp - 97;
|
||||
}
|
||||
|
||||
return self::base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do Nameprep according to RFC3491 and RFC3454
|
||||
* @param array $input Unicode Characters
|
||||
* @return string Unicode Characters, Nameprep'd
|
||||
*/
|
||||
protected function namePrep($input)
|
||||
{
|
||||
$output = [];
|
||||
//
|
||||
// Mapping
|
||||
// Walking through the input array, performing the required steps on each of
|
||||
// the input chars and putting the result into the output array
|
||||
// While mapping required chars we apply the canonical ordering
|
||||
foreach ($input as $v) {
|
||||
// Map to nothing == skip that code point
|
||||
if (in_array($v, $this->NamePrepData->mapToNothing)) {
|
||||
continue;
|
||||
}
|
||||
// Try to find prohibited input
|
||||
if (in_array($v, $this->NamePrepData->prohibit) || in_array($v, $this->NamePrepData->generalProhibited)) {
|
||||
throw new \InvalidArgumentException(sprintf('NAMEPREP: Prohibited input U+%08X', $v));
|
||||
}
|
||||
foreach ($this->NamePrepData->prohibitRanges as $range) {
|
||||
if ($range[0] <= $v && $v <= $range[1]) {
|
||||
throw new \InvalidArgumentException(sprintf('NAMEPREP: Prohibited input U+%08X', $v));
|
||||
}
|
||||
}
|
||||
|
||||
if (0xAC00 <= $v && $v <= 0xD7AF) {
|
||||
// Hangul syllable decomposition
|
||||
foreach ($this->hangulDecompose($v) as $out) {
|
||||
$output[] = (int) $out;
|
||||
}
|
||||
} elseif (isset($this->NamePrepData->replaceMaps[$v])) {
|
||||
foreach ($this->applyCanonicalOrdering($this->NamePrepData->replaceMaps[$v]) as $out) {
|
||||
$output[] = (int) $out;
|
||||
}
|
||||
} else {
|
||||
$output[] = (int) $v;
|
||||
}
|
||||
}
|
||||
// Before applying any Combining, try to rearrange any Hangul syllables
|
||||
$output = $this->hangulCompose($output);
|
||||
//
|
||||
// Combine code points
|
||||
//
|
||||
$last_class = 0;
|
||||
$last_starter = 0;
|
||||
$out_len = count($output);
|
||||
for ($i = 0; $i < $out_len; ++$i) {
|
||||
$class = $this->getCombiningClass($output[$i]);
|
||||
if ((!$last_class || $last_class > $class) && $class) {
|
||||
// Try to match
|
||||
$seq_len = $i - $last_starter;
|
||||
$out = $this->combine(array_slice($output, $last_starter, $seq_len));
|
||||
// On match: Replace the last starter with the composed character and remove
|
||||
// the now redundant non-starter(s)
|
||||
if ($out) {
|
||||
$output[$last_starter] = $out;
|
||||
if (count($out) != $seq_len) {
|
||||
for ($j = $i + 1; $j < $out_len; ++$j) {
|
||||
$output[$j - 1] = $output[$j];
|
||||
}
|
||||
unset($output[$out_len]);
|
||||
}
|
||||
// Rewind the for loop by one, since there can be more possible compositions
|
||||
$i--;
|
||||
$out_len--;
|
||||
$last_class = ($i == $last_starter) ? 0 : $this->getCombiningClass($output[$i - 1]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// The current class is 0
|
||||
if (!$class) {
|
||||
$last_starter = $i;
|
||||
}
|
||||
$last_class = $class;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decomposes a Hangul syllable
|
||||
* (see http://www.unicode.org/unicode/reports/tr15/#Hangul
|
||||
* @param integer 32bit UCS4 code point
|
||||
* @return array Either Hangul Syllable decomposed or original 32bit value as one value array
|
||||
*/
|
||||
protected function hangulDecompose($char)
|
||||
{
|
||||
$sindex = (int) $char - self::sBase;
|
||||
if ($sindex < 0 || $sindex >= self::sCount) {
|
||||
return [$char];
|
||||
}
|
||||
$result = [];
|
||||
$result[] = (int) self::lBase + $sindex / self::nCount;
|
||||
$result[] = (int) self::vBase + ($sindex % self::nCount) / self::tCount;
|
||||
$T = intval(self::tBase + $sindex % self::tCount);
|
||||
if ($T != self::tBase) {
|
||||
$result[] = $T;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ccomposes a Hangul syllable
|
||||
* (see http://www.unicode.org/unicode/reports/tr15/#Hangul
|
||||
* @param array $input Decomposed UCS4 sequence
|
||||
* @return array UCS4 sequence with syllables composed
|
||||
*/
|
||||
protected function hangulCompose($input)
|
||||
{
|
||||
$inp_len = count($input);
|
||||
if (!$inp_len) {
|
||||
return [];
|
||||
}
|
||||
$result = [];
|
||||
$last = (int) $input[0];
|
||||
$result[] = $last; // copy first char from input to output
|
||||
|
||||
for ($i = 1; $i < $inp_len; ++$i) {
|
||||
$char = (int) $input[$i];
|
||||
$sindex = $last - self::sBase;
|
||||
$lindex = $last - self::lBase;
|
||||
$vindex = $char - self::vBase;
|
||||
$tindex = $char - self::tBase;
|
||||
// Find out, whether two current characters are LV and T
|
||||
if (0 <= $sindex && $sindex < self::sCount && ($sindex % self::tCount == 0) && 0 <= $tindex && $tindex <= self::tCount) {
|
||||
// create syllable of form LVT
|
||||
$last += $tindex;
|
||||
$result[(count($result) - 1)] = $last; // reset last
|
||||
continue; // discard char
|
||||
}
|
||||
// Find out, whether two current characters form L and V
|
||||
if (0 <= $lindex && $lindex < self::lCount && 0 <= $vindex && $vindex < self::vCount) {
|
||||
// create syllable of form LV
|
||||
$last = (int) self::sBase + ($lindex * self::vCount + $vindex) * self::tCount;
|
||||
$result[(count($result) - 1)] = $last; // reset last
|
||||
continue; // discard char
|
||||
}
|
||||
// if neither case was true, just add the character
|
||||
$last = $char;
|
||||
$result[] = $char;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the combining class of a certain wide char
|
||||
* @param integer $char Wide char to check (32bit integer)
|
||||
* @return integer Combining class if found, else 0
|
||||
*/
|
||||
protected function getCombiningClass($char)
|
||||
{
|
||||
return isset($this->NamePrepData->normalizeCombiningClasses[$char])
|
||||
? $this->NamePrepData->normalizeCombiningClasses[$char]
|
||||
: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the canonical ordering of a decomposed UCS4 sequence
|
||||
* @param array $input Decomposed UCS4 sequence
|
||||
* @return array Ordered USC4 sequence
|
||||
*/
|
||||
protected function applyCanonicalOrdering($input)
|
||||
{
|
||||
$swap = true;
|
||||
$size = count($input);
|
||||
while ($swap) {
|
||||
$swap = false;
|
||||
$last = $this->getCombiningClass(intval($input[0]));
|
||||
for ($i = 0; $i < $size - 1; ++$i) {
|
||||
$next = $this->getCombiningClass(intval($input[$i + 1]));
|
||||
if ($next != 0 && $last > $next) {
|
||||
// Move item leftward until it fits
|
||||
for ($j = $i + 1; $j > 0; --$j) {
|
||||
if ($this->getCombiningClass(intval($input[$j - 1])) <= $next) {
|
||||
break;
|
||||
}
|
||||
$t = intval($input[$j]);
|
||||
$input[$j] = intval($input[$j - 1]);
|
||||
$input[$j - 1] = $t;
|
||||
$swap = true;
|
||||
}
|
||||
// Reentering the loop looking at the old character again
|
||||
$next = $last;
|
||||
}
|
||||
$last = $next;
|
||||
}
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do composition of a sequence of starter and non-starter
|
||||
* @param array $input UCS4 Decomposed sequence
|
||||
* @return array Ordered USC4 sequence
|
||||
*/
|
||||
protected function combine($input)
|
||||
{
|
||||
$inp_len = count($input);
|
||||
if (0 == $inp_len) {
|
||||
return false;
|
||||
}
|
||||
foreach ($this->NamePrepData->replaceMaps as $np_src => $np_target) {
|
||||
if ($np_target[0] != $input[0]) {
|
||||
continue;
|
||||
}
|
||||
if (count($np_target) != $inp_len) {
|
||||
continue;
|
||||
}
|
||||
$hit = false;
|
||||
foreach ($input as $k2 => $v2) {
|
||||
if ($v2 == $np_target[$k2]) {
|
||||
$hit = true;
|
||||
} else {
|
||||
$hit = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hit) {
|
||||
return $np_src;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the length of a string in bytes even if mbstring function
|
||||
* overloading is turned on
|
||||
*
|
||||
* @param string $string the string for which to get the length.
|
||||
* @return integer the length of the string in bytes.
|
||||
*/
|
||||
protected static function byteLength($string)
|
||||
{
|
||||
if (self::$isMbStringOverload) {
|
||||
return mb_strlen($string, '8bit');
|
||||
}
|
||||
return strlen((binary) $string);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* @author Matthias Sommerfeld <mso@phlylabs.de>
|
||||
* @copyright 2004-2016 phlyLabs Berlin, http://phlylabs.de
|
||||
*/
|
||||
|
||||
namespace Mso\IdnaConvert;
|
||||
|
||||
interface PunycodeInterface
|
||||
{
|
||||
|
||||
public function __construct(NamePrepDataInterface $NamePrepData, UnicodeTranscoderInterface $UCTC);
|
||||
|
||||
public function getPunycodePrefix();
|
||||
|
||||
public function decode($encoded);
|
||||
|
||||
public function encode($decoded);
|
||||
|
||||
}
|
||||
@@ -1,358 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* UCTC - The Unicode Transcoder
|
||||
*
|
||||
* Converts between various flavours of Unicode representations like UCS-4 or UTF-8
|
||||
* Supported schemes:
|
||||
* - UCS-4 Little Endian / Big Endian / Array (partially)
|
||||
* - UTF-16 Little Endian / Big Endian (not yet)
|
||||
* - UTF-8
|
||||
* - UTF-7
|
||||
* - UTF-7 IMAP (modified UTF-7)
|
||||
*
|
||||
* @package IdnaConvert
|
||||
* @author Matthias Sommerfeld <mso@phlyLabs.de>
|
||||
* @copyright 2003-2016 phlyLabs Berlin, http://phlylabs.de
|
||||
* @version 0.1.1 2016-01-24
|
||||
*/
|
||||
|
||||
namespace Mso\IdnaConvert;
|
||||
|
||||
class UnicodeTranscoder implements UnicodeTranscoderInterface
|
||||
{
|
||||
private static $mechs = ['ucs4', 'ucs4array', 'utf8', 'utf7', 'utf7imap'];
|
||||
// unsupported yet: 'ucs4le', 'ucs4be', 'utf16', 'utf16le', 'utf16be'
|
||||
|
||||
private static $allow_overlong = false;
|
||||
private static $safe_mode;
|
||||
private static $safe_char;
|
||||
|
||||
/**
|
||||
* The actual conversion routine
|
||||
*
|
||||
* @param mixed $data The data to convert, usually a string, array when converting from UCS-4 array
|
||||
* @param string $from Original encoding of the data
|
||||
* @param string $to Target encoding of the data
|
||||
* @param bool $safe_mode SafeMode tries to correct invalid codepoints
|
||||
* @param int $safe_char Unicode Codepoint as placeholder for all otherwise broken characters
|
||||
* @return mixed False on failure, String or array on success, depending on target encoding
|
||||
* @access public
|
||||
* @throws \InvalidArgumentException
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC)
|
||||
{
|
||||
self::$safe_mode = ($safe_mode) ? true : false;
|
||||
self::$safe_char = ($safe_char) ? $safe_char : 0xFFFC;
|
||||
|
||||
if (self::$safe_mode) {
|
||||
self::$allow_overlong = true;
|
||||
}
|
||||
if (!in_array($from, self::$mechs)) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid input format %s', $from));
|
||||
}
|
||||
if (!in_array($to, self::$mechs)) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid output format %s', $to));
|
||||
}
|
||||
if ($from != 'ucs4array') {
|
||||
$methodName = $from.'_ucs4array';
|
||||
$data = self::$methodName($data);
|
||||
}
|
||||
if ($to != 'ucs4array') {
|
||||
$methodName = 'ucs4array_'.$to;
|
||||
$data = self::$methodName($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This converts an UTF-8 encoded string to its UCS-4 representation
|
||||
*
|
||||
* @param string $input The UTF-8 string to convert
|
||||
* @return array Array of 32bit values representing each codepoint
|
||||
* @throws \InvalidArgumentException
|
||||
* @access public
|
||||
*/
|
||||
public static function utf8_ucs4array($input)
|
||||
{
|
||||
$start_byte = $next_byte = 0;
|
||||
|
||||
$output = [];
|
||||
$out_len = 0;
|
||||
$inp_len = self::byteLength($input);
|
||||
$mode = 'next';
|
||||
$test = 'none';
|
||||
for ($k = 0; $k < $inp_len; ++$k) {
|
||||
$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;
|
||||
if ('add' == $mode) {
|
||||
if (self::$safe_mode) {
|
||||
$output[$out_len - 2] = self::$safe_char;
|
||||
$mode = 'next';
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('Conversion from UTF-8 to UCS-4 failed: malformed input at byte %d', $k));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char
|
||||
$start_byte = $v;
|
||||
$mode = 'add';
|
||||
$test = 'range';
|
||||
if ($v >> 5 == 6) { // &110xxxxx 10xxxxx
|
||||
$next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left
|
||||
$v = ($v - 192) << 6;
|
||||
} elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx
|
||||
$next_byte = 1;
|
||||
$v = ($v - 224) << 12;
|
||||
} elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
$next_byte = 2;
|
||||
$v = ($v - 240) << 18;
|
||||
} elseif (self::$safe_mode) {
|
||||
$mode = 'next';
|
||||
$output[$out_len] = self::$safe_char;
|
||||
++$out_len;
|
||||
continue;
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('This might be UTF-8, but I don\'t understand it at byte %d', $k));
|
||||
}
|
||||
if ($inp_len - $k - $next_byte < 2) {
|
||||
$output[$out_len] = self::$safe_char;
|
||||
$mode = 'no';
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('add' == $mode) {
|
||||
$output[$out_len] = (int)$v;
|
||||
++$out_len;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ('add' == $mode) {
|
||||
if (!self::$allow_overlong && $test == 'range') {
|
||||
$test = 'none';
|
||||
if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) {
|
||||
throw new \InvalidArgumentException(sprintf('Bogus UTF-8 character detected (out of legal range) at byte %d', $k));
|
||||
}
|
||||
}
|
||||
if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx
|
||||
$v = ($v - 128) << ($next_byte * 6);
|
||||
$output[($out_len - 1)] += $v;
|
||||
--$next_byte;
|
||||
} else {
|
||||
if (self::$safe_mode) {
|
||||
$output[$out_len - 1] = ord(self::$safe_char);
|
||||
$k--;
|
||||
$mode = 'next';
|
||||
continue;
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('Conversion from UTF-8 to UCS-4 failed: malformed input at byte %d', $k));
|
||||
}
|
||||
}
|
||||
if ($next_byte < 0) {
|
||||
$mode = 'next';
|
||||
}
|
||||
}
|
||||
} // for
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert UCS-4 arary into UTF-8 string
|
||||
* See utf8_ucs4array() for details
|
||||
* @param $input array Array of UCS-4 codepoints
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public static function ucs4array_utf8($input)
|
||||
{
|
||||
$output = '';
|
||||
foreach ($input as $k => $v) {
|
||||
if ($v < 128) { // 7bit are transferred literally
|
||||
$output .= chr($v);
|
||||
} elseif ($v < (1 << 11)) { // 2 bytes
|
||||
$output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63));
|
||||
} elseif ($v < (1 << 16)) { // 3 bytes
|
||||
$output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
|
||||
} elseif ($v < (1 << 21)) { // 4 bytes
|
||||
$output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
|
||||
} elseif (self::$safe_mode) {
|
||||
$output .= self::$safe_char;
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('Conversion from UCS-4 to UTF-8 failed: malformed input at byte %d', $k));
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function utf7imap_ucs4array($input)
|
||||
{
|
||||
return self::utf7_ucs4array(str_replace(',', '/', $input), '&');
|
||||
}
|
||||
|
||||
public static function utf7_ucs4array($input, $sc = '+')
|
||||
{
|
||||
$output = [];
|
||||
$out_len = 0;
|
||||
$inp_len = self::byteLength($input);
|
||||
$mode = 'd';
|
||||
$b64 = '';
|
||||
|
||||
for ($k = 0; $k < $inp_len; ++$k) {
|
||||
$c = $input{$k};
|
||||
|
||||
// Ignore zero bytes
|
||||
if (0 == ord($c)) {
|
||||
continue;
|
||||
}
|
||||
if ('b' == $mode) {
|
||||
// Sequence got terminated
|
||||
if (!preg_match('![A-Za-z0-9/' . preg_quote($sc, '!') . ']!', $c)) {
|
||||
if ('-' == $c) {
|
||||
if ($b64 == '') {
|
||||
$output[$out_len] = ord($sc);
|
||||
$out_len++;
|
||||
$mode = 'd';
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$tmp = base64_decode($b64);
|
||||
$tmp = substr($tmp, -1 * (strlen($tmp) % 2));
|
||||
for ($i = 0; $i < strlen($tmp); $i++) {
|
||||
if ($i % 2) {
|
||||
$output[$out_len] += ord($tmp{$i});
|
||||
$out_len++;
|
||||
} else {
|
||||
$output[$out_len] = ord($tmp{$i}) << 8;
|
||||
}
|
||||
}
|
||||
$mode = 'd';
|
||||
$b64 = '';
|
||||
|
||||
continue;
|
||||
} else {
|
||||
$b64 .= $c;
|
||||
}
|
||||
}
|
||||
if ('d' == $mode) {
|
||||
if ($sc == $c) {
|
||||
$mode = 'b';
|
||||
|
||||
continue;
|
||||
}
|
||||
$output[$out_len] = ord($c);
|
||||
$out_len++;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function ucs4array_utf7imap($input)
|
||||
{
|
||||
return str_replace('/', ',', self::ucs4array_utf7($input, '&'));
|
||||
}
|
||||
|
||||
public static function ucs4array_utf7($input, $sc = '+')
|
||||
{
|
||||
$output = '';
|
||||
$mode = 'd';
|
||||
$b64 = '';
|
||||
while (true) {
|
||||
$v = (!empty($input)) ? array_shift($input) : false;
|
||||
$is_direct = (false !== $v) ? (0x20 <= $v && $v <= 0x7e && $v != ord($sc)) : true;
|
||||
if ($mode == 'b') {
|
||||
if ($is_direct) {
|
||||
if ($b64 == chr(0) . $sc) {
|
||||
$output .= $sc . '-';
|
||||
$b64 = '';
|
||||
} elseif ($b64) {
|
||||
$output .= $sc . str_replace('=', '', base64_encode($b64)) . '-';
|
||||
$b64 = '';
|
||||
}
|
||||
$mode = 'd';
|
||||
} elseif (false !== $v) {
|
||||
$b64 .= chr(($v >> 8) & 255) . chr($v & 255);
|
||||
}
|
||||
}
|
||||
if ($mode == 'd' && false !== $v) {
|
||||
if ($is_direct) {
|
||||
$output .= chr($v);
|
||||
} else {
|
||||
$b64 = chr(($v >> 8) & 255) . chr($v & 255);
|
||||
$mode = 'b';
|
||||
}
|
||||
}
|
||||
if (false === $v && $b64 == '') break;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert UCS-4 array into UCS-4 string (Little Endian at the moment)
|
||||
* @param $input array UCS-4 code points
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public static function ucs4array_ucs4($input)
|
||||
{
|
||||
$output = '';
|
||||
foreach ($input as $v) {
|
||||
$output .= chr(($v >> 24) & 255) . chr(($v >> 16) & 255) . chr(($v >> 8) & 255) . chr($v & 255);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert UCS-4 string (LE ar the moment) into UCS-4 array
|
||||
* @param $input string UCS-4 LE string
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public static function ucs4_ucs4array($input)
|
||||
{
|
||||
$output = [];
|
||||
|
||||
$inp_len = self::byteLength($input);
|
||||
// Input length must be dividable by 4
|
||||
if ($inp_len % 4) {
|
||||
throw new \InvalidArgumentException('Input UCS4 string is broken');
|
||||
}
|
||||
// Empty input - return empty output
|
||||
if (!$inp_len) return $output;
|
||||
|
||||
for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) {
|
||||
if (!($i % 4)) { // Increment output position every 4 input bytes
|
||||
$out_len++;
|
||||
$output[$out_len] = 0;
|
||||
}
|
||||
$output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4)));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the length of a string in bytes even if mbstring function
|
||||
* overloading is turned on
|
||||
*
|
||||
* @param string $string the string for which to get the length.
|
||||
* @return integer the length of the string in bytes.
|
||||
*/
|
||||
protected static function byteLength($string)
|
||||
{
|
||||
if ((extension_loaded('mbstring') && (ini_get('mbstring.func_overload') & 0x02) === 0x02)) {
|
||||
return mb_strlen($string, '8bit');
|
||||
}
|
||||
return strlen((binary) $string);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* UCTC - The Unicode Transcoder
|
||||
*
|
||||
* Converts between various flavours of Unicode representations like UCS-4 or UTF-8
|
||||
* Supported schemes:
|
||||
* - UCS-4 Little Endian / Big Endian / Array (partially)
|
||||
* - UTF-16 Little Endian / Big Endian (not yet)
|
||||
* - UTF-8
|
||||
* - UTF-7
|
||||
* - UTF-7 IMAP (modified UTF-7)
|
||||
*
|
||||
* @package IdnaConvert
|
||||
* @author Matthias Sommerfeld <mso@phlyLabs.de>
|
||||
* @copyright 2003-2016 phlyLabs Berlin, http://phlylabs.de
|
||||
* @version 0.1.0 2016-01-08
|
||||
*/
|
||||
|
||||
namespace Mso\IdnaConvert;
|
||||
|
||||
interface UnicodeTranscoderInterface
|
||||
{
|
||||
public static function convert($data, $from, $to, $safe_mode = false, $safe_char = 0xFFFC);
|
||||
|
||||
public static function utf8_ucs4array($input);
|
||||
|
||||
public static function ucs4array_utf8($input);
|
||||
|
||||
public static function utf7imap_ucs4array($input);
|
||||
|
||||
public static function utf7_ucs4array($input, $sc = '+');
|
||||
|
||||
public static function ucs4array_utf7imap($input);
|
||||
|
||||
public static function ucs4array_utf7($input, $sc = '+');
|
||||
|
||||
public static function ucs4array_ucs4($input);
|
||||
|
||||
public static function ucs4_ucs4array($input);
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user