Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1416 → Rev 1417

/trunk/vendor/spomky-labs/php-punycode/.scrutinizer.yml
0,0 → 1,21
before_commands:
- "composer install --no-interaction"
 
checks:
php:
code_rating: true
duplication: true
 
tools:
php_sim: true
php_changetracking: true
php_cpd: true
php_mess_detector: true
php_code_sniffer: true
php_analyzer: true
sensiolabs_security_checker: true
php_code_coverage: false
php_pdepend:
excluded_dirs: [vendor, doc, tests]
filter:
excluded_paths: [vendor/*, doc/*, tests/*]
/trunk/vendor/spomky-labs/php-punycode/.travis.yml
0,0 → 1,19
language: php
 
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- nightly
 
before_script:
- composer install
- mkdir -p build/logs
 
script:
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml
 
after_success:
- vendor/bin/coveralls --no-interaction
/trunk/vendor/spomky-labs/php-punycode/LICENSE
0,0 → 1,23
The MIT License
 
Copyright (c) 2015 Florent Morselli
 
Original code from 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.
/trunk/vendor/spomky-labs/php-punycode/README.md
0,0 → 1,60
Punycode
========
 
[![Build Status](https://travis-ci.org/Spomky-Labs/php-punycode.svg)](https://travis-ci.org/Spomky-Labs/php-punycode)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Spomky-Labs/php-punycode/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Spomky-Labs/php-punycode/?branch=master)
 
[![Coverage Status](https://coveralls.io/repos/Spomky-Labs/php-punycode/badge.svg?branch=master&service=github)](https://coveralls.io/github/Spomky-Labs/php-punycode?branch=master)
 
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/d59a9463-ed65-4304-a764-04f62d3fd58c/big.png)](https://insight.sensiolabs.com/projects/d59a9463-ed65-4304-a764-04f62d3fd58c)
 
[![Latest Stable Version](https://poser.pugx.org/spomky-labs/php-punycode/v/stable.png)](https://packagist.org/packages/spomky-labs/php-punycode)
[![Total Downloads](https://poser.pugx.org/spomky-labs/php-punycode/downloads.png)](https://packagist.org/packages/spomky-labs/php-punycode)
[![Latest Unstable Version](https://poser.pugx.org/spomky-labs/php-punycode/v/unstable.png)](https://packagist.org/packages/spomky-labs/php-punycode)
[![License](https://poser.pugx.org/spomky-labs/php-punycode/license.png)](https://packagist.org/packages/spomky-labs/php-punycode)
 
 
A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA).
 
Original code from https://github.com/true/php-punycode
 
# The Release Process
 
The release process [is described here](doc/Release.md).
 
# Prerequisites
 
This library needs at least ![PHP 5.4+](https://img.shields.io/badge/PHP-5.4%2B-ff69b4.svg).
 
It has been successfully tested using `PHP 5.4` to `PHP 5.6`, `PHP 7` (`7.0` and nightly) and `HHVM`.
 
# Installation
 
The preferred way to install this library is to rely on Composer:
 
```sh
composer require "spomky-labs/php-punycode"
```
 
# How to use
 
```php
<?php
 
// Import Punycode
use SpomkyLabs\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
```
 
# Contributing
 
Requests for new features, bug fixed and all other ideas to make this library useful are welcome. [Please follow these best practices](doc/Contributing.md).
 
# Licence
 
This library is release under [MIT licence](LICENSE.txt).
/trunk/vendor/spomky-labs/php-punycode/composer.json
0,0 → 1,33
{
"name": "spomky-labs/php-punycode",
"description": "A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)",
"keywords": ["IDNA", "punycode"],
"homepage": "https://github.com/spomky-labs/php-punycode",
"license": "MIT",
"authors": [
{
"name": "Renan Gonçalves",
"email": "renan.saddam@gmail.com"
},
{
"name": "Florent Morselli"
},
{
"name": "All contributors",
"homepage": "https://github.com/Spomky-Labs/oauth2-server-library/contributors"
}
],
"autoload": {
"psr-4": {
"SpomkyLabs\\": "src/"
}
},
"require": {
"php": ">=5.4",
"symfony/polyfill-mbstring": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.0",
"satooshi/php-coveralls": "^1.0"
}
}
/trunk/vendor/spomky-labs/php-punycode/doc/Contributing.md
0,0 → 1,26
Contributing
============
 
First of all, **thank you** for contributing.
 
Bugs or feature requests can be posted online on the GitHub issues section of the project.
 
Few rules to ease code reviews and merges:
 
- You MUST follow the [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/) and [PSR-4](http://www.php-fig.org/psr/psr-4/) coding standards.
- You MUST run the test suite.
- You MUST write (or update) unit tests when bugs are fixed or features are added.
- You SHOULD write documentation.
 
We use [Git-Flow](http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/) to automate our git branching workflow.
 
To contribute use [Pull Requests](https://help.github.com/articles/using-pull-requests), please, write commit messages that make sense, and rebase your branch before submitting your PR.
 
May be asked to squash your commits too. This is used to "clean" your Pull Request before merging it, avoiding commits such as fix tests, fix 2, fix 3, etc.
 
Run test suite
------------
 
* install composer: `curl -s http://getcomposer.org/installer | php`
* install dependencies: `php composer.phar install`
* run tests: `vendor/bin/phpunit`
/trunk/vendor/spomky-labs/php-punycode/doc/Release.md
0,0 → 1,19
The Release Process
===================
 
We manage its releases through features and time-based models.
 
- A new patch version comes out every month when you made backwards-compatible bug fixes.
- A new minor version comes every six months when we added functionality in a backwards-compatible manner.
- A new major version comes every year when we make incompatible API changes.
 
The meaning of "patch" "minor" and "major" comes from the Semantic [Versioning strategy](http://semver.org/).
 
This release process applies from version 3.0.x.
 
Backwards Compatibility
-----------------------
 
We allow developers to upgrade with confidence from one minor version to the next one.
 
Whenever keeping backward compatibility is not possible, the feature, the enhancement or the bug fix will be scheduled for the next major version.
/trunk/vendor/spomky-labs/php-punycode/phpunit.xml.dist
0,0 → 1,29
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
 
<filter>
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
<directory>./tests</directory>
<directory>./doc</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
/trunk/vendor/spomky-labs/php-punycode/src/Punycode.php
0,0 → 1,330
<?php
 
namespace SpomkyLabs;
 
/**
* Punycode implementation as described in RFC 3492.
*
* @link http://tools.ietf.org/html/rfc3492
*/
final 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
*/
private static $encodeTable = [
'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
*/
private static $decodeTable = [
'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,
];
 
/**
* Encode a domain to its Punycode version.
*
* @param string $input Domain name in Unicode to be encoded
* @param string $encoding Character encoding
*
* @return string Punycode representation in ASCII
*/
public static function encode($input, $encoding = 'UTF-8')
{
$input = mb_strtolower($input, $encoding);
$parts = explode('.', $input);
foreach ($parts as &$part) {
$part = self::encodePart($part, $encoding);
}
 
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
* @param string $encoding Character encoding
*
* @return string Punycode representation of a domain part
*/
private static function encodePart($input, $encoding)
{
$codePoints = self::listCodePoints($input, $encoding);
 
$n = static::INITIAL_N;
$bias = static::INITIAL_BIAS;
$delta = 0;
$h = $b = count($codePoints['basic']);
 
$output = '';
foreach ($codePoints['basic'] as $code) {
$output .= self::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, $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 = self::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 = self::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
* @param string $encoding Character encoding
*
* @return string Unicode domain name
*/
public static function decode($input, $encoding = 'UTF-8')
{
$parts = explode('.', $input);
foreach ($parts as &$part) {
if (strpos($part, static::PREFIX) !== 0) {
continue;
}
 
$part = mb_substr($part, mb_strlen(static::PREFIX, $encoding), null, $encoding);
$part = self::decodePart($part, $encoding);
}
 
return implode('.', $parts);
}
 
/**
* Decode a part of domain name, such as tld.
*
* @param string $input Part of a domain name
* @param string $encoding Character encoding
*
* @return string Unicode domain part
*/
private static function decodePart($input, $encoding)
{
$n = static::INITIAL_N;
$i = 0;
$bias = static::INITIAL_BIAS;
$output = '';
 
$pos = mb_strrpos($input, static::DELIMITER, null, $encoding);
if ($pos !== false) {
$output = mb_substr($input, 0, $pos++, $encoding);
} else {
$pos = 0;
}
 
$outputLength = mb_strlen($output, $encoding);
$inputLength = mb_strlen($input, $encoding);
while ($pos < $inputLength) {
$oldi = $i;
$w = 1;
 
for ($k = static::BASE; ; $k += static::BASE) {
$digit = static::$decodeTable[$input[$pos++]];
$i = $i + ($digit * $w);
$t = self::calculateThreshold($k, $bias);
 
if ($digit < $t) {
break;
}
 
$w = $w * (static::BASE - $t);
}
 
$bias = self::adapt($i - $oldi, ++$outputLength, ($oldi === 0));
$n = $n + (int) ($i / $outputLength);
$i = $i % ($outputLength);
$output = mb_substr($output, 0, $i, $encoding).self::codePointToChar($n).mb_substr($output, $i, $outputLength - 1, $encoding);
 
++$i;
}
 
return $output;
}
 
/**
* Calculate the bias threshold to fall between TMIN and TMAX.
*
* @param int $k
* @param int $bias
*
* @return int
*/
private static 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 int $delta
* @param int $numPoints
* @param bool $firstTime
*
* @return int
*/
private static 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
* @param string $encoding
*
* @return array Multi-dimension array with basic, non-basic and aggregated code points
*/
private static function listCodePoints($input, $encoding)
{
$codePoints = [
'all' => [],
'basic' => [],
'nonBasic' => [],
];
 
$length = mb_strlen($input, $encoding);
for ($i = 0; $i < $length; ++$i) {
$char = mb_substr($input, $i, 1, $encoding);
$code = self::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 int
*/
private static 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 int $code
*
* @return string
*/
private static 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);
}
}
}