$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:----Z4e8e9A+qLXxv46C2kkINcbvWbw3AzJNFzaMyTTdTJM9ecuLov/DNihNaGlU6EVDv3Zt8eelwwe8im+g2AXlWzr2lpwSA3QaAy9gvYALolOSDW0znnHAi1O+PMhiqvGpnC7kdKGY4iQHb7yv9BxYCudD4WgR3iWbHjOSuDflVQxpgb4oHz4wMpEt0bd4AgR2POcCqi5GLzxDm5oHLLZl8TQ6deKmeRNGK5bEzyltWiiPRY3qjcnQXcdp/mW+ivdD7ZVv2YnFMALGFh0SmK9WKSmvTAuLf6v/8vg+s+xyWwt4F+T1rMxXYNhk1gdlu9fl5ZsJPxieZvgwYgEMEtsASLK9BdD1c4zFclI19MrAth8QglViL6/0G9uFJ6Hg3zyB/eM7eacTcxvjUVGuPIFLwuDi78z4c5qJRlGqAd/qK++99XGqZ73VVyveJCTb6JlQ1wrWOoeg3zuZVlf/QH+z8UnOkgwXDA1p2TP4xJsC+mKUZBp+5DNFfO9RX6Nq6QQQXdfyYCJAvTokIsH1PjvO1TIuCIBs1hosb25l3o+mt5Rcj0ncaQx7QzomoEX39jE5ri/+qG/uyWZ6n0z6QEHhY1U1LZTISev5EHwJG8queVcVlJ0VKU68wLXcOXFIM9bkm53K2JKOKzw5rIiUiPiq4P5+M0etfU8w5DhPskouNZU=----ATTACHMENT:----ODU0MjAwOTMwNDIwMzk3MSA5NjI1OTMyMjkzODc2ODM1IDUyMzYxMjE1MjIzODg1NA==