ALPHA 3.0.2

This commit is contained in:
TheGamecraft
2018-09-05 11:35:41 -04:00
parent 4dbdc8fd19
commit 8ef8057bfa
771 changed files with 9284 additions and 5857 deletions

View File

@@ -376,10 +376,10 @@ EOF;
if ($hostRegex) {
preg_match('#^.\^(.*)\$.[a-zA-Z]*$#', $hostRegex, $rx);
$state->vars = array();
$hostRegex = '(?i:'.preg_replace_callback('#\?P<([^>]++)>#', $state->getVars, $rx[1]).')';
$hostRegex = '(?i:'.preg_replace_callback('#\?P<([^>]++)>#', $state->getVars, $rx[1]).')\.';
$state->hostVars = $state->vars;
} else {
$hostRegex = '[^/]*+';
$hostRegex = '(?:(?:[^.]*+\.)++)';
$state->hostVars = array();
}
$state->mark += strlen($rx = ($prev ? ')' : '')."|{$hostRegex}(?");
@@ -406,6 +406,7 @@ EOF;
$rx = ")$}{$modifiers}";
$code .= "\n .'{$rx}',";
$state->regex .= $rx;
$state->markTail = 0;
// if the regex is too large, throw a signaling exception to recompute with smaller chunk size
set_error_handler(function ($type, $message) { throw 0 === strpos($message, $this->signalingException->getMessage()) ? $this->signalingException : new \ErrorException($message); });
@@ -427,7 +428,7 @@ EOF;
EOF;
}
$matchedPathinfo = $matchHost ? '$host.$pathinfo' : '$pathinfo';
$matchedPathinfo = $matchHost ? '$host.\'.\'.$pathinfo' : '$pathinfo';
unset($state->getVars);
return <<<EOF

View File

@@ -63,11 +63,9 @@ class StaticPrefixCollection
*
* @param array|self $route
*/
public function addRoute(string $prefix, $route, string $staticPrefix = null)
public function addRoute(string $prefix, $route)
{
if (null === $staticPrefix) {
list($prefix, $staticPrefix) = $this->getCommonPrefix($prefix, $prefix);
}
list($prefix, $staticPrefix) = $this->getCommonPrefix($prefix, $prefix);
for ($i = \count($this->items) - 1; 0 <= $i; --$i) {
$item = $this->items[$i];
@@ -102,7 +100,7 @@ class StaticPrefixCollection
if ($item instanceof self && $this->prefixes[$i] === $commonPrefix) {
// the new route is a child of a previous one, let's nest it
$item->addRoute($prefix, $route, $staticPrefix);
$item->addRoute($prefix, $route);
} else {
// the new route and a previous one have a common prefix, let's merge them
$child = new self($commonPrefix);
@@ -187,6 +185,12 @@ class StaticPrefixCollection
}
}
restore_error_handler();
if ($i < $end && 0b10 === (\ord($prefix[$i]) >> 6) && preg_match('//u', $prefix.' '.$anotherPrefix)) {
do {
// Prevent cutting in the middle of an UTF-8 characters
--$i;
} while (0b10 === (\ord($prefix[$i]) >> 6));
}
return array(substr($prefix, 0, $i), substr($prefix, 0, $staticLength ?? $i));
}