Parsing
@param string $url
@param string $template
@param string $tag
@param array|int $page
@param int $cur
@return string
976285
protected function parseFragment($url, $template, $tag, $page, $cur)
    {
        $fragment = self::fetchFragment($template, $tag);
        if (empty($fragment)) {
            return $template;
        }
        $replace = '';
        if (is_array($page)) {
            foreach ($page as $number) {
                $replace .= $this->fillLink($fragment, $url, $tag, $number, $cur);
            }
        } else {
            $replace .= $this->fillLink($fragment, $url, $tag, $page, $cur);
        }

        return str_replace($fragment, $replace, $template);
    }
1061603
public function parse($url)
    {
        $content = $this->performRequest($url)->getBody()->getContents();

        $content = $this->convertEncodingToUTF8($content);

        return $this->getHtmlDomParser($content);
    }
1261690
public function parse($url)
    {
        if (!$url) {
            $url = '/';
        }

        $Routes = TableRegistry::get('Wasabi/Core.Routes');

        $route = $Routes->find()
            ->orWhere([$Routes->aliasField('page_type') => 'collection'])
            ->orWhere([$Routes->aliasField('page_type') => 'simple'])
            ->andWhere([$Routes->aliasField('url') => $url])
            ->first();

        $pageNumber = false;

        $urlParts = explode('/', $url);

        // no direct route found -> try paged collection routes
        if (!$route) {
            $part = array_pop($urlParts);

            if (preg_match('/^[0-9]+$/', $part)) {
                $pageNumber = (int)$part;
                $part = array_pop($urlParts);
            }

            // paged url found so lets try to find a proper collection route
            if ($pageNumber !== false && $part === self::PAGE_PART) {
                $route = $Routes->find()->where([
                    $Routes->aliasField('page_type') => 'collection',
                    $Routes->aliasField('url') => join('/', $urlParts)
                ])->first();
            }
        }

        if (!$route) {
            return false;
        }

        if ($route->redirect_to !== null) {
            /** @var \Wasabi\Core\Model\Entity\Route $redirectRoute */
            $redirectRoute = $Routes->get($route->redirect_to);

            $redirectUrl = $redirectRoute->url;
            $statusCode = 301;
            if ($pageNumber !== false && $pageNumber > 1) {
                $redirectUrl .= '/' . self::PAGE_PART . '/' . $pageNumber;
            }
            if ($route->status_code !== null) {
                $statusCode = (int)$route->status_code;
            }

            $this->_redirect($redirectUrl, $statusCode);
        }

        // Dispatch Wasabi.Routes.parse event to all plugin listeners to get params.
        $routesParseEvent = new Event('Wasabi.Routes.parse', $url, [
            'route' => $route,
            'pageNumber' => $pageNumber
        ]);

        EventManager::instance()->dispatch($routesParseEvent);

        if (!$routesParseEvent->isStopped() || empty($routesParseEvent->result['params'])) {
            return false;
        }

        $params = $routesParseEvent->result['params'];

        return $params;
    }
412533
public static function _parse_url_query($url)
    {
        $queryString = parse_url($url, PHP_URL_QUERY);

        $params = array();

        parse_str($queryString, $params);

        if (count($params) === 0) {
            return $params;
        }

        return array_filter($params);
    }
1127552
public static function parseStr($s, &$var, $header = false)
    {
        static $cb;
        if ($cb === null) {
            $cb = function ($m) {
                return urlencode(html_entity_decode('&#' . hexdec($m[1]) . ';', ENT_NOQUOTES, 'utf-8'));
            };
        }
        if ($header) {
            $s = strtr($s, Generic::$hvaltr);
        }
        if ((stripos($s, '%u') !== false)
            && preg_match('~(%u[a-f\d]{4}|%[c-f][a-f\d](?!%[89a-f][a-f\d]))~is', $s, $m)
        ) {
            $s = preg_replace_callback('~%(u[a-f\d]{4}|[a-f\d]{2})~i', $cb, $s);
        }
        parse_str($s, $var);
    }
514654
protected static function parseUrl($url)
    {
        $url_parts = Utils::multibyteParseUrl($url);

        if (isset($url_parts['scheme'])) {
            /** @var UniformResourceLocator $locator */
            $locator = Grav::instance()['locator'];

            // Special handling for the streams.
            if ($locator->schemeExists($url_parts['scheme'])) {
                if (isset($url_parts['host'])) {
                    // Merge host and path into a path.
                    $url_parts['path'] = $url_parts['host'] . (isset($url_parts['path']) ? '/' . $url_parts['path'] : '');
                    unset($url_parts['host']);
                }

                $url_parts['stream'] = true;
            }
        }

        return $url_parts;
    }
840837
protected function parse($url)
    {
        $html = $this->get($url)->getBody()->getContents();

        $parser = $this->getParser($html);

        return $parser;
    }
1312558
public function parseUrl($url) {
		$url = parse_url($url);
		$url['vars'] = array();
		if (!isset($url['fragment'])) {
			$url['fragment'] = null;
		}
		if (isset($url['query'])) {
			parse_str($url['query'], $url['vars']);
		}

		return $url;
	}
90346
private static function parse($url)
    {
        $enc_url = preg_replace_callback(
            '%[^:/@?&=#]+%usD',
            function ($matches) {
                return rawurlencode($matches[0]);
            },
            $url
        );

        $parts = parse_url($enc_url);

        if ($parts === false) {
            throw new \InvalidArgumentException('Malformed URL: ' . $url);
        }

        if (!empty($parts['scheme']) && !in_array($parts['scheme'], ['http', 'https', 'data'])) {
            throw new \InvalidArgumentException(sprintf('Invalid URL scheme: "%s"', $parts['scheme']));
        }

        foreach ($parts as $name => $value) {
            $parts[$name] = rawurldecode($value);
        }
        return $parts;
    }
624209
static function GatherParams($url)
    {
        $reader = new StringReader($url);
        $param = '';
        $params = array();
        $start = false;
        while (false !== ($ch = $reader->ReadChar())) {
            if ($ch == '{') {
                $start = true;
            }
            else if ($ch == '}' && $start) {
                $params[] = $param;
                $param = '';
                $start = false;
            }
            else if ($start) {
                $param .= $ch;
            }
        }
        return $params;
    }
1317925
static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE)
    {
        $components = parse_url($url);

        if ($components === false) {
            throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url));
        }

        $query = [];

        if (isset($components['query'])) {
            parse_str($components['query'], $query);
        }

        return new static(
            $components['scheme'] ?? null,
            $components['host'] ?? null,
            $components['port'] ?? null,
            $components['path'] ?? '',
            $query,
            $components['fragment'] ?? null,
            $preferredFormat
        );
    }
676406
public static function parseParams($url_parsed) {

        $vid = FALSE; $url_seperator = FALSE;

        if (preg_match('/^\/watch$/', $url_parsed['path'])) {
            // new Youtube utilizes fragment part instead of query
            $fragment_regex = '/^\!v\=([a-zA-Z0-9]+).*$/';

            if (isset($url_parsed['fragment']) && preg_match($fragment_regex, $url_parsed['fragment'])) {

                $vid = preg_replace($fragment_regex, '$1', $url_parsed['fragment']);
                $url_seperator = '#!';

            } else {

                // parse fragment parameters into query string
                if (!empty($url_parsed['fragment'])) {
                    if (!empty($url_parsed['query'])) {
                        $url_parsed['query'] = $url_parsed['query'].'&'.$url_parsed['fragment'];
                    } else {
                        $url_parsed['query'] = $url_parsed['fragment'];
                    }
                }

                // backward compatibility
                parse_str($url_parsed['query'], $args);
                if (isset($args['v'])) {
                    $vid = $args['v'];
                    $t = isset($args['t']) ? $args['t'] : '';
                    $t_fragment = !empty($t) ? '&t='.$t : '';
                    $url_seperator = '?';
                }

            }

            $location = preg_replace('/([a-z]+?)\.youtube\.com/', '$1', strtolower($url_parsed['host']));
            $string = 'http://'.$location.'.youtube.com/watch'.$url_seperator.'v='.$vid.$t_fragment;
        } elseif (preg_match('/^\/user\/[a-zA-Z0-9_\-]+$/',  $url_parsed['path'])){
            $fragment_regex = '/^p\/u\/[0-9]+\/([a-zA-Z0-9]+)/';
            if (preg_match($fragment_regex, $url_parsed['fragment'])) {
                $vid = preg_replace($fragment_regex, '$1', $url_parsed['fragment']);
            }

            $location = preg_replace('/([a-z]+?)\.youtube\.com/', '$1', strtolower($url_parsed['host']));
            $string = 'http://'.$url_parsed['host'].'/'.$url_parsed["path"].'#'.$url_parsed['fragment'];
        }


        return ($vid === FALSE) ? FALSE : array(
            'vid'           => $vid,
            'url_seperator' => $url_seperator,
            'location'      => $location,
            'string'        => $string,
            't'             => $t,
        );
    }
1255151
public function parse(array $tag, $content) {
        if (empty($tag['attributes']['default'])) {
            $email = $content;
            $default = false;
        } else {
            $email = $tag['attributes']['default'];
            $default = true;
        }

        // Return an invalid email
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            return $content;
        }

        $encrypted = '';

        if ($this->getConfig('encrypt')) {
            $length = mb_strlen($email);

            if ($length > 0) {
                for ($i = 0; $i < $length; ++$i) {
                    $encrypted .= '&#' . ord(mb_substr($email, $i, 1)) . ';';
                }
            }
        } else {
            $encrypted = $email;
        }

        $tag['attributes']['href'] = 'mailto:' . $encrypted;

        if ($this->getParser()->getConfig('shorthandLinks')) {
            $tag['content'] = $this->message('mail');

            return '[' . parent::parse($tag, $content) . ']';
        }

        if (!$default) {
            $tag['content'] = $encrypted;
        }

        return parent::parse($tag, $content);
    }
748803
protected function parseUrlParams($url, &$var = [])
    {
        if ($url) {
            if ($this->getConfig('url_param_type')) {
                $var += explode('|', $url);
            } else {
                preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) {
                    $var[$match[1]] = strip_tags($match[2]);
                }, $url);
            }
        }
    }
851106
public function parse($url) {
		// iterate all rules
		$hit = false;

		foreach ($this->_routes as $rule => $new_class) {
			$regex		= trim($rule, '/');

			// rebuild route to a preg pattern
			if (preg_match($regex, $url, $parameters)) {
				$class = preg_replace($regex, $new_class, $url);
				$class = str_replace('/', '_', $class);
				unset($parameters[0]);
				$hit = true;
				break;
			}
		}

		if ($hit === false) {
			$class = call_user_func($this->_fallback, $url);
		}

		$class_shards = explode('\\', $class);
		$class_shards[count($class_shards)-1] = ucfirst(strtolower($class_shards[count($class_shards)-1]));
		$class = implode('\\', $class_shards);

		return [
			'controller'		=> $class,
			'parameters'		=> isset($parameters) ? $parameters : [],
		];
	}
1223288
public function check(DOMElement $template, Tag $tag)
	{
		$xpath = new DOMXPath($template->ownerDocument);
		$query
			= '//*[translate(local-name(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = "' . $this->elName . '"]'
			. '|'
			. '//xsl:element[translate(@name,"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = "' . $this->elName . '"]';

		$node = $xpath->query($query)->item(0);
		if ($node)
		{
			throw new UnsafeTemplateException("Element '" . $this->elName . "' is disallowed", $node);
		}
	}
778967
public function parse($html)
    {
        $errorHandling = libxml_use_internal_errors(true);

        $dom = new \DOMDocument();
        $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);

        $xpath = new \DOMXpath($dom);

        foreach ($this->componentFactories as $tag => $factory) {
            $tags = $xpath->query('//' . $tag);

            if ($tags) {
                foreach ($tags as $node) {
                    $factory->parse($node);
                }
            }
        }

        libxml_clear_errors();
        libxml_use_internal_errors($errorHandling);

        return $dom->saveHTML();
    }