League\CommonMark\Util\RegexHelper::isLinkPotentiallyUnsafe PHP Method

isLinkPotentiallyUnsafe() public static method

public static isLinkPotentiallyUnsafe ( string $url ) : boolean
$url string
return boolean
    public static function isLinkPotentiallyUnsafe($url)
    {
        return preg_match(self::REGEX_UNSAFE_PROTOCOL, $url) !== 0 && preg_match(self::REGEX_SAFE_DATA_PROTOCOL, $url) === 0;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param Link                     $inline
  * @param ElementRendererInterface $htmlRenderer
  *
  * @return HtmlElement
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof Link) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     $attrs = [];
     foreach ($inline->getData('attributes', []) as $key => $value) {
         $attrs[$key] = $htmlRenderer->escape($value, true);
     }
     if (!($this->config->getConfig('safe') && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl()))) {
         $attrs['href'] = $htmlRenderer->escape($inline->getUrl(), true);
     }
     if (isset($inline->data['title'])) {
         $attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
     }
     return new HtmlElement('a', $attrs, $htmlRenderer->renderInlines($inline->children()));
 }
All Usage Examples Of League\CommonMark\Util\RegexHelper::isLinkPotentiallyUnsafe