diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2019-11-17 20:45:02 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2019-11-17 20:45:02 +0100 |
commit | 8df3db566a3a937b45ebf11adb90d265e6f5e2d4 (patch) | |
tree | 4d541098d751d5a9acf8c12f6fb9f308ace066ac /vendor/guzzle/guzzle/src/Guzzle/Parser/Url | |
download | flyspray-8df3db566a3a937b45ebf11adb90d265e6f5e2d4.tar.xz |
initial checking of customized version 1.0rc9
Diffstat (limited to 'vendor/guzzle/guzzle/src/Guzzle/Parser/Url')
-rw-r--r-- | vendor/guzzle/guzzle/src/Guzzle/Parser/Url/UrlParser.php | 48 | ||||
-rw-r--r-- | vendor/guzzle/guzzle/src/Guzzle/Parser/Url/UrlParserInterface.php | 19 |
2 files changed, 67 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Parser/Url/UrlParser.php b/vendor/guzzle/guzzle/src/Guzzle/Parser/Url/UrlParser.php new file mode 100644 index 0000000..c4cc896 --- /dev/null +++ b/vendor/guzzle/guzzle/src/Guzzle/Parser/Url/UrlParser.php @@ -0,0 +1,48 @@ +<?php + +namespace Guzzle\Parser\Url; + +use Guzzle\Common\Version; + +/** + * Parses URLs into parts using PHP's built-in parse_url() function + * @deprecated Just use parse_url. UTF-8 characters should be percent encoded anyways. + * @codeCoverageIgnore + */ +class UrlParser implements UrlParserInterface +{ + /** @var bool Whether or not to work with UTF-8 strings */ + protected $utf8 = false; + + /** + * Set whether or not to attempt to handle UTF-8 strings (still WIP) + * + * @param bool $utf8 Set to TRUE to handle UTF string + */ + public function setUtf8Support($utf8) + { + $this->utf8 = $utf8; + } + + public function parseUrl($url) + { + Version::warn(__CLASS__ . ' is deprecated. Just use parse_url()'); + + static $defaults = array('scheme' => null, 'host' => null, 'path' => null, 'port' => null, 'query' => null, + 'user' => null, 'pass' => null, 'fragment' => null); + + $parts = parse_url($url); + + // Need to handle query parsing specially for UTF-8 requirements + if ($this->utf8 && isset($parts['query'])) { + $queryPos = strpos($url, '?'); + if (isset($parts['fragment'])) { + $parts['query'] = substr($url, $queryPos + 1, strpos($url, '#') - $queryPos - 1); + } else { + $parts['query'] = substr($url, $queryPos + 1); + } + } + + return $parts + $defaults; + } +} diff --git a/vendor/guzzle/guzzle/src/Guzzle/Parser/Url/UrlParserInterface.php b/vendor/guzzle/guzzle/src/Guzzle/Parser/Url/UrlParserInterface.php new file mode 100644 index 0000000..89ac4b3 --- /dev/null +++ b/vendor/guzzle/guzzle/src/Guzzle/Parser/Url/UrlParserInterface.php @@ -0,0 +1,19 @@ +<?php + +namespace Guzzle\Parser\Url; + +/** + * URL parser interface + */ +interface UrlParserInterface +{ + /** + * Parse a URL using special handling for a subset of UTF-8 characters in the query string if needed. + * + * @param string $url URL to parse + * + * @return array Returns an array identical to what is returned from parse_url(). When an array key is missing from + * this array, you must fill it in with NULL to avoid warnings in calling code. + */ + public function parseUrl($url); +} |