aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/uri
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/uri')
-rw-r--r--vendor/sabre/uri/.gitignore13
-rw-r--r--vendor/sabre/uri/.travis.yml14
-rw-r--r--vendor/sabre/uri/CHANGELOG.md34
-rw-r--r--vendor/sabre/uri/LICENSE27
-rw-r--r--vendor/sabre/uri/README.md55
-rw-r--r--vendor/sabre/uri/lib/Version.php19
-rw-r--r--vendor/sabre/uri/lib/functions.php282
7 files changed, 444 insertions, 0 deletions
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 @@
+<?php
+
+namespace Sabre\Uri;
+
+/**
+ * This class contains the version number for this package.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/
+ */
+class Version {
+
+ /**
+ * Full version number
+ */
+ const VERSION = '1.1.0';
+
+}
diff --git a/vendor/sabre/uri/lib/functions.php b/vendor/sabre/uri/lib/functions.php
new file mode 100644
index 000000000..06181aef0
--- /dev/null
+++ b/vendor/sabre/uri/lib/functions.php
@@ -0,0 +1,282 @@
+<?php
+
+namespace Sabre\Uri;
+
+/**
+ * This file contains all the uri handling functions.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/
+ */
+
+/**
+ * Resolves relative urls, like a browser would.
+ *
+ * This function takes a basePath, which itself _may_ also be relative, and
+ * then applies the relative path on top of it.
+ *
+ * @param string $basePath
+ * @param string $newPath
+ * @return string
+ */
+function resolve($basePath, $newPath) {
+
+ $base = parse($basePath);
+ $delta = parse($newPath);
+
+ $pick = function($part) use ($base, $delta) {
+
+ if ($delta[$part]) {
+ return $delta[$part];
+ } elseif ($base[$part]) {
+ return $base[$part];
+ }
+ return null;
+
+ };
+
+ // If the new path defines a scheme, it's absolute and we can just return
+ // that.
+ if ($delta['scheme']) {
+ return build($delta);
+ }
+
+ $newParts = [];
+
+ $newParts['scheme'] = $pick('scheme');
+ $newParts['host'] = $pick('host');
+ $newParts['port'] = $pick('port');
+
+ $path = '';
+ if ($delta['path']) {
+ // If the path starts with a slash
+ if ($delta['path'][0] === '/') {
+ $path = $delta['path'];
+ } else {
+ // Removing last component from base path.
+ $path = $base['path'];
+ if (strpos($path, '/') !== false) {
+ $path = substr($path, 0, strrpos($path, '/'));
+ }
+ $path .= '/' . $delta['path'];
+ }
+ } else {
+ $path = $base['path'] ?: '/';
+ }
+ // Removing .. and .
+ $pathParts = explode('/', $path);
+ $newPathParts = [];
+ foreach ($pathParts as $pathPart) {
+
+ switch ($pathPart) {
+ //case '' :
+ case '.' :
+ break;
+ case '..' :
+ array_pop($newPathParts);
+ break;
+ default :
+ $newPathParts[] = $pathPart;
+ break;
+ }
+ }
+
+ $path = implode('/', $newPathParts);
+
+ // If the source url ended with a /, we want to preserve that.
+ $newParts['path'] = $path;
+ if ($delta['query']) {
+ $newParts['query'] = $delta['query'];
+ } elseif (!empty($base['query']) && empty($delta['host']) && empty($delta['path'])) {
+ // Keep the old query if host and path didn't change
+ $newParts['query'] = $base['query'];
+ }
+ if ($delta['fragment']) {
+ $newParts['fragment'] = $delta['fragment'];
+ }
+ return build($newParts);
+
+}
+
+/**
+ * Takes a URI or partial URI as its argument, and normalizes it.
+ *
+ * After normalizing a URI, you can safely compare it to other URIs.
+ * This function will for instance convert a %7E into a tilde, according to
+ * rfc3986.
+ *
+ * It will also change a %3a into a %3A.
+ *
+ * @param string $uri
+ * @return string
+ */
+function normalize($uri) {
+
+ $parts = parse($uri);
+
+ if (!empty($parts['path'])) {
+ $pathParts = explode('/', ltrim($parts['path'], '/'));
+ $newPathParts = [];
+ foreach ($pathParts as $pathPart) {
+ switch ($pathPart) {
+ case '.':
+ // skip
+ break;
+ case '..' :
+ // One level up in the hierarchy
+ array_pop($newPathParts);
+ break;
+ default :
+ // Ensuring that everything is correctly percent-encoded.
+ $newPathParts[] = rawurlencode(rawurldecode($pathPart));
+ break;
+ }
+ }
+ $parts['path'] = '/' . implode('/', $newPathParts);
+ }
+
+ if ($parts['scheme']) {
+ $parts['scheme'] = strtolower($parts['scheme']);
+ $defaultPorts = [
+ 'http' => '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];
+
+}