From 79561eff6f687e23cf2cc5c5017283658e228d5c Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Tue, 10 Dec 2019 21:29:45 +0000 Subject: Update vendor dependencies --- vendor/league/commonmark/CHANGELOG.md | 9 +++- .../commonmark/src/Block/Element/FencedCode.php | 2 +- .../src/Block/Parser/ATXHeadingParser.php | 2 + .../league/commonmark/src/CommonMarkConverter.php | 2 +- vendor/league/commonmark/src/Cursor.php | 1 + vendor/league/commonmark/src/DocParser.php | 1 + vendor/league/commonmark/src/HtmlElement.php | 23 +++++++--- vendor/league/commonmark/src/Util/RegexHelper.php | 3 ++ vendor/league/commonmark/src/Util/UrlEncoder.php | 52 +++++++++++++++------- 9 files changed, 69 insertions(+), 26 deletions(-) (limited to 'vendor/league/commonmark') diff --git a/vendor/league/commonmark/CHANGELOG.md b/vendor/league/commonmark/CHANGELOG.md index 59251af019..7713f8ff01 100644 --- a/vendor/league/commonmark/CHANGELOG.md +++ b/vendor/league/commonmark/CHANGELOG.md @@ -4,6 +4,12 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi ## [Unreleased][unreleased] +## [1.1.2] - 2019-12-09 + +### Fixed + + - Fixed URL normalization not handling non-UTF-8 sequences properly (#395, #396) + ## [1.1.1] - 2019-11-11 ### Fixed @@ -174,7 +180,8 @@ No changes were made since 1.0.0-rc1. - Removed `DelimiterStack::iterateByCharacters()` (use the new `processDelimiters()` method instead) - Removed the protected `DelimiterStack::findMatchingOpener()` method -[unreleased]: https://github.com/thephpleague/commonmark/compare/1.1.1...HEAD +[unreleased]: https://github.com/thephpleague/commonmark/compare/1.1.2...HEAD +[1.1.2]: https://github.com/thephpleague/commonmark/compare/1.1.1...1.1.2 [1.1.1]: https://github.com/thephpleague/commonmark/compare/1.1.0...1.1.1 [1.1.0]: https://github.com/thephpleague/commonmark/compare/1.0.0...1.1.0 [1.0.0]: https://github.com/thephpleague/commonmark/compare/1.0.0-rc1...1.0.0 diff --git a/vendor/league/commonmark/src/Block/Element/FencedCode.php b/vendor/league/commonmark/src/Block/Element/FencedCode.php index e0bd610273..ea4e263648 100644 --- a/vendor/league/commonmark/src/Block/Element/FencedCode.php +++ b/vendor/league/commonmark/src/Block/Element/FencedCode.php @@ -67,7 +67,7 @@ class FencedCode extends AbstractStringContainerBlock */ public function getInfoWords(): array { - return \preg_split('/\s+/', $this->info); + return \preg_split('/\s+/', $this->info) ?: []; } /** diff --git a/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php b/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php index c39ea3f312..0448f441e2 100644 --- a/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php +++ b/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php @@ -44,7 +44,9 @@ final class ATXHeadingParser implements BlockParserInterface $level = \strlen(\trim($match[0])); $str = $cursor->getRemainder(); + /** @var string $str */ $str = \preg_replace('/^[ \t]*#+[ \t]*$/', '', $str); + /** @var string $str */ $str = \preg_replace('/[ \t]+#+[ \t]*$/', '', $str); $context->addBlock(new Heading($level, $str)); diff --git a/vendor/league/commonmark/src/CommonMarkConverter.php b/vendor/league/commonmark/src/CommonMarkConverter.php index 46071cc88b..cd14268e12 100644 --- a/vendor/league/commonmark/src/CommonMarkConverter.php +++ b/vendor/league/commonmark/src/CommonMarkConverter.php @@ -24,7 +24,7 @@ class CommonMarkConverter extends Converter * * This might be a typical `x.y.z` version, or `x.y-dev`. */ - public const VERSION = '1.1.1'; + public const VERSION = '1.1.2'; /** @var EnvironmentInterface */ protected $environment; diff --git a/vendor/league/commonmark/src/Cursor.php b/vendor/league/commonmark/src/Cursor.php index 33e0d3db9b..19a31e6492 100644 --- a/vendor/league/commonmark/src/Cursor.php +++ b/vendor/league/commonmark/src/Cursor.php @@ -247,6 +247,7 @@ class Cursor if ($characters === 1 && !empty($nextFewChars)) { $asArray = [$nextFewChars]; } elseif ($this->isMultibyte) { + /** @var string[] $asArray */ $asArray = \preg_split('//u', $nextFewChars, -1, \PREG_SPLIT_NO_EMPTY); } else { $asArray = \str_split($nextFewChars); diff --git a/vendor/league/commonmark/src/DocParser.php b/vendor/league/commonmark/src/DocParser.php index 76906ec494..299256e167 100644 --- a/vendor/league/commonmark/src/DocParser.php +++ b/vendor/league/commonmark/src/DocParser.php @@ -55,6 +55,7 @@ final class DocParser implements DocParserInterface */ private function preProcessInput(string $input): array { + /** @var string[] $lines */ $lines = \preg_split('/\r\n|\n|\r/', $input); // Remove any newline which appears at the very end of the string. diff --git a/vendor/league/commonmark/src/HtmlElement.php b/vendor/league/commonmark/src/HtmlElement.php index 415d65b833..19f997538c 100644 --- a/vendor/league/commonmark/src/HtmlElement.php +++ b/vendor/league/commonmark/src/HtmlElement.php @@ -103,15 +103,11 @@ class HtmlElement */ public function getContents(bool $asString = true) { - if (!$asString || \is_string($this->contents)) { + if (!$asString) { return $this->contents; } - if (\is_array($this->contents)) { - return \implode('', $this->contents); - } - - return (string) $this->contents; + return $this->getContentsAsString(); } /** @@ -140,7 +136,7 @@ class HtmlElement } if ($this->contents !== '') { - $result .= '>' . $this->getContents() . 'tagName . '>'; + $result .= '>' . $this->getContentsAsString() . 'tagName . '>'; } elseif ($this->selfClosing) { $result .= ' />'; } else { @@ -149,4 +145,17 @@ class HtmlElement return $result; } + + private function getContentsAsString(): string + { + if (\is_string($this->contents)) { + return $this->contents; + } + + if (\is_array($this->contents)) { + return \implode('', $this->contents); + } + + return (string) $this->contents; + } } diff --git a/vendor/league/commonmark/src/Util/RegexHelper.php b/vendor/league/commonmark/src/Util/RegexHelper.php index 611b1b38f0..86cb3da924 100644 --- a/vendor/league/commonmark/src/Util/RegexHelper.php +++ b/vendor/league/commonmark/src/Util/RegexHelper.php @@ -141,7 +141,10 @@ final class RegexHelper { $allEscapedChar = '/\\\\(' . self::PARTIAL_ESCAPABLE . ')/'; + /** @var string $escaped */ $escaped = \preg_replace($allEscapedChar, '$1', $string); + + /** @var string $replaced */ $replaced = \preg_replace_callback('/' . self::PARTIAL_ENTITY . '/i', function ($e) { return Html5EntityDecoder::decode($e[0]); }, $escaped); diff --git a/vendor/league/commonmark/src/Util/UrlEncoder.php b/vendor/league/commonmark/src/Util/UrlEncoder.php index f808e39415..527fc57277 100644 --- a/vendor/league/commonmark/src/Util/UrlEncoder.php +++ b/vendor/league/commonmark/src/Util/UrlEncoder.php @@ -40,17 +40,17 @@ final class UrlEncoder ]; protected static $dontDecode = [ - ';', - '/', - '?', - ':', - '@', - '&', - '=', - '+', - '$', - ',', - '#', + '%3B' => ';', + '%2F' => '/', + '%3F' => '?', + '%3A' => ':', + '%40' => '@', + '%26' => '&', + '%3D' => '=', + '%2B' => '+', + '%24' => '$', + '%2C' => ',', + '%23' => '#', ]; /** @@ -74,15 +74,32 @@ final class UrlEncoder */ private static function decode(string $uri): string { - return \preg_replace_callback('/%([0-9a-f]{2})/iu', function ($matches) { - $char = \chr(\hexdec($matches[1])); + /** @var string $ret */ + $ret = \preg_replace_callback('/((?:%[0-9a-f]{2})+)/iu', function ($matches) { + $bytes = \hex2bin(\str_replace('%', '', $matches[1])); - if (\in_array($char, self::$dontDecode, true)) { + // Invalid UTF-8 sequences should be kept as-is + if ($bytes === false || !\mb_check_encoding($bytes, 'UTF-8')) { return \strtoupper($matches[0]); } - return $char; + // Otherwise, split the sequence into characters and decode them (unless that character shouldn't be decoded) + /** @var string[] $characters */ + $characters = \preg_split('//u', $bytes, -1, \PREG_SPLIT_NO_EMPTY); + + $ret = ''; + foreach ($characters as $char) { + if (($encoding = \array_search($char, self::$dontDecode, true)) !== false) { + $ret .= $encoding; + } else { + $ret .= $char; + } + } + + return $ret; }, $uri); + + return $ret; } /** @@ -94,7 +111,8 @@ final class UrlEncoder */ private static function encode(string $uri): string { - return \preg_replace_callback('/(%[0-9a-f]{2})|./isu', function ($matches) { + /** @var string $ret */ + $ret = \preg_replace_callback('/(%[0-9a-f]{2})|./isu', function ($matches) { // Keep already-encoded characters as-is if (\count($matches) > 1) { return $matches[0]; @@ -108,5 +126,7 @@ final class UrlEncoder // Otherwise, encode the character return \rawurlencode($matches[0]); }, $uri); + + return $ret; } } -- cgit v1.3