Import additional composer dependencies

This commit is contained in:
Kijin Sung 2016-01-13 14:03:48 +09:00
parent 01dd26783f
commit c3dc2c68f3
439 changed files with 67918 additions and 138 deletions

3
vendor/true/punycode/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
build/
vendor/
composer.lock

31
vendor/true/punycode/.travis.yml vendored Normal file
View file

@ -0,0 +1,31 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
matrix:
fast_finish: true
include:
- php: 5.3
env: PHPCS=1
sudo: false
before_script:
- composer self-update
- composer install
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then mkdir -p build/logs; fi
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
script:
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then ./vendor/bin/phpunit --coverage-text; fi
- if [[ "$PHPCS" == "1" ]]; then ./vendor/bin/phpcs --standard=PSR2 -np src/ tests/; fi
after_script:
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi

35
vendor/true/punycode/CHANGELOG.md vendored Normal file
View file

@ -0,0 +1,35 @@
# Changelog
## 2.0.2 - 2016-01-07
- [Fix] Encode and decode domains regardless of their casing (#16)
- Thanks to [@abcdmitry](https://github.com/abcdmitry) for the full patch.
## 2.0.1 - 2015-09-01
- [Fix] Removed `version` property from `composer.json` file
- Thanks to [@GrahamCampbell](https://github.com/GrahamCampbell) for the patch.
## 2.0.0 - 2015-06-24
- [Enhancement] PHP 7 support
- [Fix] Renamed `True` namespace to `TrueBV` as it is a reserved word in PHP 7
## 1.1.0 - 2015-03-12
- [Enhancement] Character encoding is now passed to the constructor, defaulting to UTF-8, as opposite to relying on `mb_internal_encoding` function call (#9).
## 1.0.1 - 2014-08-26
- [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) compliant and automation on Travis-CI
- Thanks to [@nyamsprod](https://github.com/nyamsprod) for initial patch.
- [Fix] Domain containing `x`, `n` or `-` would result in failures while decoding (#6).
## 1.0.0 - 2014-03-10
- Initial release

19
vendor/true/punycode/LICENSE vendored Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2014 TrueServer B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

45
vendor/true/punycode/README.md vendored Normal file
View file

@ -0,0 +1,45 @@
# Punycode
[![Build Status](https://secure.travis-ci.org/true/php-punycode.png?branch=master)](http://travis-ci.org/true/php-punycode)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/true/php-punycode/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/true/php-punycode/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/true/php-punycode/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/true/php-punycode/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/true/punycode/version.png)](https://packagist.org/packages/true/punycode)
A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA).
## Install
```
composer require true/punycode:~2.0
```
## Usage
```php
<?php
// Import Punycode
use TrueBV\Punycode;
$Punycode = new Punycode();
var_dump($Punycode->encode('renangonçalves.com'));
// outputs: xn--renangonalves-pgb.com
var_dump($Punycode->decode('xn--renangonalves-pgb.com'));
// outputs: renangonçalves.com
```
## FAQ
### 1. What is this library for?
This library converts a Unicode encoded domain name to a IDNA ASCII form and vice-versa.
### 2. Why should I use this instead of [PHP's IDN Functions](http://php.net/manual/en/ref.intl.idn.php)?
If you can compile the needed dependencies (intl, libidn) there is not much difference.
But if you want to write portable code between hosts (including Windows and Mac OS), or can't install PECL extensions, this is the right library for you.

26
vendor/true/punycode/composer.json vendored Normal file
View file

@ -0,0 +1,26 @@
{
"name": "true/punycode",
"description": "A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)",
"keywords": ["IDNA", "punycode"],
"homepage": "https://github.com/true/php-punycode",
"license": "MIT",
"authors": [
{
"name": "Renan Gonçalves",
"email": "renan.saddam@gmail.com"
}
],
"autoload": {
"psr-4": {
"TrueBV\\": "src/"
}
},
"require": {
"php": ">=5.3.0",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.7",
"squizlabs/php_codesniffer": "~2.0"
}
}

17
vendor/true/punycode/phpunit.xml.dist vendored Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<phpunit bootstrap="vendor/autoload.php" colors="true" verbose="true">
<testsuites>
<testsuite name="Punycode Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
<blacklist>
<directory>tests</directory>
<directory>vendor</directory>
</blacklist>
</filter>
</phpunit>

334
vendor/true/punycode/src/Punycode.php vendored Normal file
View file

@ -0,0 +1,334 @@
<?php
namespace TrueBV;
/**
* Punycode implementation as described in RFC 3492
*
* @link http://tools.ietf.org/html/rfc3492
*/
class Punycode
{
/**
* Bootstring parameter values
*
*/
const BASE = 36;
const TMIN = 1;
const TMAX = 26;
const SKEW = 38;
const DAMP = 700;
const INITIAL_BIAS = 72;
const INITIAL_N = 128;
const PREFIX = 'xn--';
const DELIMITER = '-';
/**
* Encode table
*
* @param array
*/
protected static $encodeTable = array(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
);
/**
* Decode table
*
* @param array
*/
protected static $decodeTable = array(
'a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5,
'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11,
'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17,
's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23,
'y' => 24, 'z' => 25, '0' => 26, '1' => 27, '2' => 28, '3' => 29,
'4' => 30, '5' => 31, '6' => 32, '7' => 33, '8' => 34, '9' => 35
);
/**
* Character encoding
*
* @param string
*/
protected $encoding;
/**
* Constructor
*
* @param string $encoding Character encoding
*/
public function __construct($encoding = 'UTF-8')
{
$this->encoding = $encoding;
}
/**
* Encode a domain to its Punycode version
*
* @param string $input Domain name in Unicode to be encoded
* @return string Punycode representation in ASCII
*/
public function encode($input)
{
$input = mb_strtolower($input, $this->encoding);
$parts = explode('.', $input);
foreach ($parts as &$part) {
$part = $this->encodePart($part);
}
return implode('.', $parts);
}
/**
* Encode a part of a domain name, such as tld, to its Punycode version
*
* @param string $input Part of a domain name
* @return string Punycode representation of a domain part
*/
protected function encodePart($input)
{
$codePoints = $this->listCodePoints($input);
$n = static::INITIAL_N;
$bias = static::INITIAL_BIAS;
$delta = 0;
$h = $b = count($codePoints['basic']);
$output = '';
foreach ($codePoints['basic'] as $code) {
$output .= $this->codePointToChar($code);
}
if ($input === $output) {
return $output;
}
if ($b > 0) {
$output .= static::DELIMITER;
}
$codePoints['nonBasic'] = array_unique($codePoints['nonBasic']);
sort($codePoints['nonBasic']);
$i = 0;
$length = mb_strlen($input, $this->encoding);
while ($h < $length) {
$m = $codePoints['nonBasic'][$i++];
$delta = $delta + ($m - $n) * ($h + 1);
$n = $m;
foreach ($codePoints['all'] as $c) {
if ($c < $n || $c < static::INITIAL_N) {
$delta++;
}
if ($c === $n) {
$q = $delta;
for ($k = static::BASE;; $k += static::BASE) {
$t = $this->calculateThreshold($k, $bias);
if ($q < $t) {
break;
}
$code = $t + (($q - $t) % (static::BASE - $t));
$output .= static::$encodeTable[$code];
$q = ($q - $t) / (static::BASE - $t);
}
$output .= static::$encodeTable[$q];
$bias = $this->adapt($delta, $h + 1, ($h === $b));
$delta = 0;
$h++;
}
}
$delta++;
$n++;
}
return static::PREFIX . $output;
}
/**
* Decode a Punycode domain name to its Unicode counterpart
*
* @param string $input Domain name in Punycode
* @return string Unicode domain name
*/
public function decode($input)
{
$input = strtolower($input);
$parts = explode('.', $input);
foreach ($parts as &$part) {
if (strpos($part, static::PREFIX) !== 0) {
continue;
}
$part = substr($part, strlen(static::PREFIX));
$part = $this->decodePart($part);
}
return implode('.', $parts);
}
/**
* Decode a part of domain name, such as tld
*
* @param string $input Part of a domain name
* @return string Unicode domain part
*/
protected function decodePart($input)
{
$n = static::INITIAL_N;
$i = 0;
$bias = static::INITIAL_BIAS;
$output = '';
$pos = strrpos($input, static::DELIMITER);
if ($pos !== false) {
$output = substr($input, 0, $pos++);
} else {
$pos = 0;
}
$outputLength = strlen($output);
$inputLength = strlen($input);
while ($pos < $inputLength) {
$oldi = $i;
$w = 1;
for ($k = static::BASE;; $k += static::BASE) {
$digit = static::$decodeTable[$input[$pos++]];
$i = $i + ($digit * $w);
$t = $this->calculateThreshold($k, $bias);
if ($digit < $t) {
break;
}
$w = $w * (static::BASE - $t);
}
$bias = $this->adapt($i - $oldi, ++$outputLength, ($oldi === 0));
$n = $n + (int) ($i / $outputLength);
$i = $i % ($outputLength);
$output = mb_substr($output, 0, $i, $this->encoding) . $this->codePointToChar($n) . mb_substr($output, $i, $outputLength - 1, $this->encoding);
$i++;
}
return $output;
}
/**
* Calculate the bias threshold to fall between TMIN and TMAX
*
* @param integer $k
* @param integer $bias
* @return integer
*/
protected function calculateThreshold($k, $bias)
{
if ($k <= $bias + static::TMIN) {
return static::TMIN;
} elseif ($k >= $bias + static::TMAX) {
return static::TMAX;
}
return $k - $bias;
}
/**
* Bias adaptation
*
* @param integer $delta
* @param integer $numPoints
* @param boolean $firstTime
* @return integer
*/
protected function adapt($delta, $numPoints, $firstTime)
{
$delta = (int) (
($firstTime)
? $delta / static::DAMP
: $delta / 2
);
$delta += (int) ($delta / $numPoints);
$k = 0;
while ($delta > ((static::BASE - static::TMIN) * static::TMAX) / 2) {
$delta = (int) ($delta / (static::BASE - static::TMIN));
$k = $k + static::BASE;
}
$k = $k + (int) (((static::BASE - static::TMIN + 1) * $delta) / ($delta + static::SKEW));
return $k;
}
/**
* List code points for a given input
*
* @param string $input
* @return array Multi-dimension array with basic, non-basic and aggregated code points
*/
protected function listCodePoints($input)
{
$codePoints = array(
'all' => array(),
'basic' => array(),
'nonBasic' => array(),
);
$length = mb_strlen($input, $this->encoding);
for ($i = 0; $i < $length; $i++) {
$char = mb_substr($input, $i, 1, $this->encoding);
$code = $this->charToCodePoint($char);
if ($code < 128) {
$codePoints['all'][] = $codePoints['basic'][] = $code;
} else {
$codePoints['all'][] = $codePoints['nonBasic'][] = $code;
}
}
return $codePoints;
}
/**
* Convert a single or multi-byte character to its code point
*
* @param string $char
* @return integer
*/
protected function charToCodePoint($char)
{
$code = ord($char[0]);
if ($code < 128) {
return $code;
} elseif ($code < 224) {
return (($code - 192) * 64) + (ord($char[1]) - 128);
} elseif ($code < 240) {
return (($code - 224) * 4096) + ((ord($char[1]) - 128) * 64) + (ord($char[2]) - 128);
} else {
return (($code - 240) * 262144) + ((ord($char[1]) - 128) * 4096) + ((ord($char[2]) - 128) * 64) + (ord($char[3]) - 128);
}
}
/**
* Convert a code point to its single or multi-byte character
*
* @param integer $code
* @return string
*/
protected function codePointToChar($code)
{
if ($code <= 0x7F) {
return chr($code);
} elseif ($code <= 0x7FF) {
return chr(($code >> 6) + 192) . chr(($code & 63) + 128);
} elseif ($code <= 0xFFFF) {
return chr(($code >> 12) + 224) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
} else {
return chr(($code >> 18) + 240) . chr((($code >> 12) & 63) + 128) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
}
}
}

View file

@ -0,0 +1,151 @@
<?php
namespace TrueBV;
class PunycodeTest extends \PHPUnit_Framework_TestCase
{
/**
* Test encoding Punycode
*
* @param string $decoded Decoded domain
* @param string $encoded Encoded domain
* @dataProvider domainNamesProvider
*/
public function testEncode($decoded, $encoded)
{
$Punycode = new Punycode();
$result = $Punycode->encode($decoded);
$this->assertEquals($encoded, $result);
}
/**
* Test decoding Punycode
*
* @param string $decoded Decoded domain
* @param string $encoded Encoded domain
* @dataProvider domainNamesProvider
*/
public function testDecode($decoded, $encoded)
{
$Punycode = new Punycode();
$result = $Punycode->decode($encoded);
$this->assertEquals($decoded, $result);
}
/**
* Test encoding Punycode in uppercase
*
* @param string $decoded Decoded domain
* @param string $encoded Encoded domain
* @dataProvider domainNamesProvider
*/
public function testEncodeUppercase($decoded, $encoded)
{
$Punycode = new Punycode();
$result = $Punycode->encode(mb_strtoupper($decoded, 'UTF-8'));
$this->assertEquals($encoded, $result);
}
/**
* Test decoding Punycode in uppercase
*
* @param string $decoded Decoded domain
* @param string $encoded Encoded domain
* @dataProvider domainNamesProvider
*/
public function testDecodeUppercase($decoded, $encoded)
{
$Punycode = new Punycode();
$result = $Punycode->decode(strtoupper($encoded));
$this->assertEquals($decoded, $result);
}
/**
* Provide domain names containing the decoded and encoded names
*
* @return array
*/
public function domainNamesProvider()
{
return array(
// http://en.wikipedia.org/wiki/.test_(international_domain_name)#Test_TLDs
array(
'مثال.إختبار',
'xn--mgbh0fb.xn--kgbechtv',
),
array(
'مثال.آزمایشی',
'xn--mgbh0fb.xn--hgbk6aj7f53bba',
),
array(
'例子.测试',
'xn--fsqu00a.xn--0zwm56d',
),
array(
'例子.測試',
'xn--fsqu00a.xn--g6w251d',
),
array(
'пример.испытание',
'xn--e1afmkfd.xn--80akhbyknj4f',
),
array(
'उदाहरण.परीक्षा',
'xn--p1b6ci4b4b3a.xn--11b5bs3a9aj6g',
),
array(
'παράδειγμα.δοκιμή',
'xn--hxajbheg2az3al.xn--jxalpdlp',
),
array(
'실례.테스트',
'xn--9n2bp8q.xn--9t4b11yi5a',
),
array(
'בײַשפּיל.טעסט',
'xn--fdbk5d8ap9b8a8d.xn--deba0ad',
),
array(
'例え.テスト',
'xn--r8jz45g.xn--zckzah',
),
array(
'உதாரணம்.பரிட்சை',
'xn--zkc6cc5bi7f6e.xn--hlcj6aya9esc7a',
),
array(
'derhausüberwacher.de',
'xn--derhausberwacher-pzb.de',
),
array(
'renangonçalves.com',
'xn--renangonalves-pgb.com',
),
array(
'рф.ru',
'xn--p1ai.ru',
),
array(
'δοκιμή.gr',
'xn--jxalpdlp.gr',
),
array(
'ফাহাদ্১৯.বাংলা',
'xn--65bj6btb5gwimc.xn--54b7fta0cc',
),
array(
'𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑.gr',
'xn--uba5533kmaba1adkfh6ch2cg.gr',
),
array(
'guangdong.广东',
'guangdong.xn--xhq521b',
),
array(
'gwóźdź.pl',
'xn--gwd-hna98db.pl',
),
);
}
}