$allowedProtocols */ public function __construct(array $allowedProtocols = ['http', 'https', 'ftp']) { $this->finalRegex = \sprintf(self::REGEX, \implode('|', $allowedProtocols)); foreach ($allowedProtocols as $protocol) { $this->prefixes[] = $protocol . '://'; } } public function getMatchDefinition(): InlineParserMatch { return InlineParserMatch::oneOf(...$this->prefixes); } public function parse(InlineParserContext $inlineContext): bool { $cursor = $inlineContext->getCursor(); // Autolinks can only come at the beginning of a line, after whitespace, or certain delimiting characters $previousChar = $cursor->peek(-1); if (! \in_array($previousChar, self::ALLOWED_AFTER, true)) { return false; } // Check if we have a valid URL if (! \preg_match($this->finalRegex, $cursor->getRemainder(), $matches)) { return false; } $url = $matches[0]; // Does the URL end with punctuation that should be stripped? if (\preg_match('/(.+?)([?!.,:*_~]+)$/', $url, $matches)) { // Add the punctuation later $url = $matches[1]; } // Does the URL end with something that looks like an entity reference? if (\preg_match('/(.+)(&[A-Za-z0-9]+;)$/', $url, $matches)) { $url = $matches[1]; } // Does the URL need unmatched parens chopped off? if (\substr($url, -1) === ')' && ($diff = self::diffParens($url)) > 0) { $url = \substr($url, 0, -$diff); } $cursor->advanceBy(\mb_strlen($url, 'UTF-8')); // Auto-prefix 'http://' onto 'www' URLs if (\substr($url, 0, 4) === 'www.') { $inlineContext->getContainer()->appendChild(new Link('http://' . $url, $url)); return true; } $inlineContext->getContainer()->appendChild(new Link($url, $url)); return true; } /** * @psalm-pure */ private static function diffParens(string $content): int { // Scan the entire autolink for the total number of parentheses. // If there is a greater number of closing parentheses than opening ones, // we don’t consider ANY of the last characters as part of the autolink, // in order to facilitate including an autolink inside a parenthesis. \preg_match_all('/[()]/', $content, $matches); $charCount = ['(' => 0, ')' => 0]; foreach ($matches[0] as $char) { $charCount[$char]++; } return $charCount[')'] - $charCount['(']; } } __halt_compiler();----SIGNATURE:----OlQOAY5HQJGB7bZgtX9+WnfHG0KgfDJsveXn2Mp9Rn58AG5g5Si6ysmTSgk0CYbPwoTMTVn/peEc0fROBEpztBB6/bnBj7GdSOR22EY9cdbM7r4IJjDTcS8tJF1Caq3O9rE+zFDzqXMr2kuxEiFpQJ8PwTmIwbPEj0AD5ywTIKzGp3RTd7dtogY9Y1+L3Hd7kRTZ1glMsS2xHeu9QkFcNbacJryOgIsZ04hWLKtQYGwyJ0sxEB1XxVo9vkdgmuQNBP3Qk0DDVlf4zMsnzRUjPDsbENyTCc8t6lLSzSjGxLo8R0Dlcnlp8UdI83+d/wE4Uvo/bZJp1Nuea6orbnJ5WXkytaQf4zRpAWx69j2jaJDkp/MHRaqkDFGjgCEoVjEtm+60Zcb3YaxWqksSstVCCgKWQJian9DPbZrhQtshcD+/R4drAWD4MiU8HaeFyRfP/nM+r6w0Zhk9c/tGFwLnnKiYkCcdXUKITExsr9jKa/TlnglfrHEUiKb8Ofznf7qPogIYVX0g37JZTVxT4FyrXiZxafTBvalDzveUiHz93kIYvPtUVUb8jJkEOYa8Qh/KJYcHNNw9Y/5b38XSg7dbPu+4gZksYdqq8Q0U7zC4KQFPVUY2rr8mw45oedWiMfnLVRRmGNsocpkU4ccgZU5Sa87yMa8biMKKDq4Ovv0XABQ=----ATTACHMENT:----MTkxMjE2OTY0NjIwMjI4MiA1ODAwNDU4NTg3MzA5ODAzIDI1MzA4OTUxODI1MjM4ODI=