From 0b02a6d123b2014705998c94ddf3d460948d3eac Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 10 May 2016 17:26:44 -0700 Subject: initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import) --- vendor/sabre/uri/.gitignore | 13 ++ vendor/sabre/uri/.travis.yml | 14 ++ vendor/sabre/uri/CHANGELOG.md | 34 +++++ vendor/sabre/uri/LICENSE | 27 ++++ vendor/sabre/uri/README.md | 55 ++++++++ vendor/sabre/uri/lib/Version.php | 19 +++ vendor/sabre/uri/lib/functions.php | 282 +++++++++++++++++++++++++++++++++++++ 7 files changed, 444 insertions(+) create mode 100644 vendor/sabre/uri/.gitignore create mode 100644 vendor/sabre/uri/.travis.yml create mode 100644 vendor/sabre/uri/CHANGELOG.md create mode 100644 vendor/sabre/uri/LICENSE create mode 100644 vendor/sabre/uri/README.md create mode 100644 vendor/sabre/uri/lib/Version.php create mode 100644 vendor/sabre/uri/lib/functions.php (limited to 'vendor/sabre/uri') diff --git a/vendor/sabre/uri/.gitignore b/vendor/sabre/uri/.gitignore new file mode 100644 index 000000000..19d1affd4 --- /dev/null +++ b/vendor/sabre/uri/.gitignore @@ -0,0 +1,13 @@ +# Composer +vendor/ +composer.lock + +# Tests +tests/cov/ + +# Composer binaries +bin/phpunit +bin/phpcs + +# Vim +.*.swp diff --git a/vendor/sabre/uri/.travis.yml b/vendor/sabre/uri/.travis.yml new file mode 100644 index 000000000..f7d1a0657 --- /dev/null +++ b/vendor/sabre/uri/.travis.yml @@ -0,0 +1,14 @@ +language: php +php: + - 5.4 + - 5.5 + - 5.6 + - hhvm + - 7 + +script: + - ./bin/phpunit --configuration tests/phpunit.xml.dist + - ./bin/sabre-cs-fixer fix lib/ --dry-run --diff + +before_script: composer install --dev + diff --git a/vendor/sabre/uri/CHANGELOG.md b/vendor/sabre/uri/CHANGELOG.md new file mode 100644 index 000000000..9fa510dc2 --- /dev/null +++ b/vendor/sabre/uri/CHANGELOG.md @@ -0,0 +1,34 @@ +ChangeLog +========= + +1.1.0 (2016-03-07) +------------------ + +* #6: PHP's `parse_url()` corrupts strings if they contain certain + non ascii-characters such as Chinese or Hebrew. sabre/uri's `parse()` + function now percent-encodes these characters beforehand. + + +1.0.1 (2015-04-28) +------------------ + +* #4: Using php-cs-fixer to automatically enforce conding standards. +* #5: Resolving to and building `mailto:` urls were not correctly handled. + + +1.0.0 (2015-01-27) +------------------ + +* Added a `normalize` function. +* Added a `buildUri` function. +* Fixed a bug in the `resolve` when only a new fragment is specified. + +San José, CalConnect XXXII release! + +0.0.1 (2014-11-17) +------------------ + +* First version! +* Source was lifted from sabre/http package. +* Provides a `resolve` and a `split` function. +* Requires PHP 5.4.8 and up. diff --git a/vendor/sabre/uri/LICENSE b/vendor/sabre/uri/LICENSE new file mode 100644 index 000000000..9a3a91946 --- /dev/null +++ b/vendor/sabre/uri/LICENSE @@ -0,0 +1,27 @@ +Copyright (C) 2014-2016 fruux GmbH (https://fruux.com/) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name Sabre nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/sabre/uri/README.md b/vendor/sabre/uri/README.md new file mode 100644 index 000000000..76f55d8e4 --- /dev/null +++ b/vendor/sabre/uri/README.md @@ -0,0 +1,55 @@ +sabre/uri +========= + +sabre/uri is a lightweight library that provides several functions for working +with URIs, staying true to the rules of [RFC3986][2]. + +Partially inspired by [Node.js URL library][3], and created to solve real +problems in PHP applications. 100% unitested and many tests are based on +examples from RFC3986. + +The library provides the following functions: + +1. `resolve` to resolve relative urls. +2. `normalize` to aid in comparing urls. +3. `parse`, which works like PHP's [parse_url][6]. +4. `build` to do the exact opposite of `parse`. +5. `split` to easily get the 'dirname' and 'basename' of a URL without all the + problems those two functions have. + + +Further reading +--------------- + +* [Installation][7] +* [Usage][8] + + +Build status +------------ + +| branch | status | +| ------ | ------ | +| master | [![Build Status](https://travis-ci.org/fruux/sabre-uri.svg?branch=master)](https://travis-ci.org/fruux/sabre-uri) | + + +Questions? +---------- + +Head over to the [sabre/dav mailinglist][4], or you can also just open a ticket +on [GitHub][5]. + + +Made at fruux +------------- + +This library is being developed by [fruux](https://fruux.com/). Drop us a line for commercial services or enterprise support. + +[1]: http://sabre.io/uri/ +[2]: https://tools.ietf.org/html/rfc3986/ +[3]: http://nodejs.org/api/url.html +[4]: http://groups.google.com/group/sabredav-discuss +[5]: https://github.com/fruux/sabre-uri/issues/ +[6]: http://php.net/manual/en/function.parse-url.php +[7]: http://sabre.io/uri/install/ +[8]: http://sabre.io/uri/usage/ diff --git a/vendor/sabre/uri/lib/Version.php b/vendor/sabre/uri/lib/Version.php new file mode 100644 index 000000000..88678d4d5 --- /dev/null +++ b/vendor/sabre/uri/lib/Version.php @@ -0,0 +1,19 @@ + '80', + 'https' => '443', + ]; + + if (!empty($parts['port']) && isset($defaultPorts[$parts['scheme']]) && $defaultPorts[$parts['scheme']] == $parts['port']) { + // Removing default ports. + unset($parts['port']); + } + // A few HTTP specific rules. + switch ($parts['scheme']) { + case 'http' : + case 'https' : + if (empty($parts['path'])) { + // An empty path is equivalent to / in http. + $parts['path'] = '/'; + } + break; + } + } + + if ($parts['host']) $parts['host'] = strtolower($parts['host']); + + return build($parts); + +} + +/** + * Parses a URI and returns its individual components. + * + * This method largely behaves the same as PHP's parse_url, except that it will + * return an array with all the array keys, including the ones that are not + * set by parse_url, which makes it a bit easier to work with. + * + * Unlike PHP's parse_url, it will also convert any non-ascii characters to + * percent-encoded strings. PHP's parse_url corrupts these characters on OS X. + * + * @param string $uri + * @return array + */ +function parse($uri) { + + // Normally a URI must be ASCII, however. However, often it's not and + // parse_url might corrupt these strings. + // + // For that reason we take any non-ascii characters from the uri and + // uriencode them first. + $uri = preg_replace_callback( + '/[^[:ascii:]]/u', + function($matches) { + return rawurlencode($matches[0]); + }, + $uri + ); + + return + parse_url($uri) + [ + 'scheme' => null, + 'host' => null, + 'path' => null, + 'port' => null, + 'user' => null, + 'query' => null, + 'fragment' => null, + ]; + +} + +/** + * This function takes the components returned from PHP's parse_url, and uses + * it to generate a new uri. + * + * @param array $parts + * @return string + */ +function build(array $parts) { + + $uri = ''; + + $authority = ''; + if (!empty($parts['host'])) { + $authority = $parts['host']; + if (!empty($parts['user'])) { + $authority = $parts['user'] . '@' . $authority; + } + if (!empty($parts['port'])) { + $authority = $authority . ':' . $parts['port']; + } + } + + if (!empty($parts['scheme'])) { + // If there's a scheme, there's also a host. + $uri = $parts['scheme'] . ':'; + + } + if ($authority) { + // No scheme, but there is a host. + $uri .= '//' . $authority; + + } + + if (!empty($parts['path'])) { + $uri .= $parts['path']; + } + if (!empty($parts['query'])) { + $uri .= '?' . $parts['query']; + } + if (!empty($parts['fragment'])) { + $uri .= '#' . $parts['fragment']; + } + + return $uri; + +} + +/** + * Returns the 'dirname' and 'basename' for a path. + * + * The reason there is a custom function for this purpose, is because + * basename() is locale aware (behaviour changes if C locale or a UTF-8 locale + * is used) and we need a method that just operates on UTF-8 characters. + * + * In addition basename and dirname are platform aware, and will treat + * backslash (\) as a directory separator on windows. + * + * This method returns the 2 components as an array. + * + * If there is no dirname, it will return an empty string. Any / appearing at + * the end of the string is stripped off. + * + * @param string $path + * @return array + */ +function split($path) { + + $matches = []; + if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u', $path, $matches)) { + return [$matches[1], $matches[2]]; + } + return [null,null]; + +} -- cgit v1.2.3