Commit a40f2d11 authored by catch's avatar catch
Browse files

fix: #3029122 Drupal returns a 500 Internal error when 'destination' url query...

fix: #3029122 Drupal returns a 500 Internal error when 'destination' url query value is numeric and less than 6 length

By: thihathit
By: chi
By: smustgrave
By: steven jones
By: catch
By: alexpott
(cherry picked from commit ecaa384d)
parent af82c328
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -59,7 +59,10 @@ public function assemble($uri, array $options = [], $collect_bubbleable_metadata
    // Note that UrlHelper::isExternal will return FALSE if the $uri has a
    // disallowed protocol.  This is later made safe since we always add at
    // least a leading slash.
    if (parse_url($uri, PHP_URL_SCHEME) === 'base') {
    // parse_url can return inconsistent results for some urls, so perform a
    // simple string comparison for the 'base:' scheme, but further validate
    // that parse_url can parse the URI at all.
    if (strncasecmp($uri, 'base:', 5) === 0 && parse_url($uri, PHP_URL_SCHEME) !== FALSE) {
      return $this->buildLocalUrl($uri, $options, $collect_bubbleable_metadata);
    }
    elseif (UrlHelper::isExternal($uri)) {
+2 −0
Original line number Diff line number Diff line
@@ -153,11 +153,13 @@ public function testAssembleWithLocalUri($uri, array $options, $subdir, $expecte
  public static function providerTestAssembleWithLocalUri(): array {
    return [
      ['base:example', [], FALSE, '/example'],
      ['base:1978', [], FALSE, '/1978'],
      ['base:example', ['query' => ['foo' => 'bar']], FALSE, '/example?foo=bar'],
      ['base:example', ['query' => ['foo' => '"bar"']], FALSE, '/example?foo=%22bar%22'],
      ['base:example', ['query' => ['foo' => '"bar"', 'zoo' => 'baz']], FALSE, '/example?foo=%22bar%22&zoo=baz'],
      ['base:example', ['fragment' => 'example'], FALSE, '/example#example'],
      ['base:example', [], TRUE, '/subdir/example'],
      ['base:1978', [], TRUE, '/subdir/1978'],
      ['base:example', ['query' => ['foo' => 'bar']], TRUE, '/subdir/example?foo=bar'],
      ['base:example', ['fragment' => 'example'], TRUE, '/subdir/example#example'],
      ['base:/drupal.org', [], FALSE, '/drupal.org'],