- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/textparser.php
- Класс: CTextParser
- Вызов: CTextParser::convert_anchor_tag
public function convert_anchor_tag($url, $text)
{
$url = trim(str_replace(['[nomodify]', '[/nomodify]'], '', $url));
$text = trim(str_replace(['[nomodify]', '[/nomodify]'], '', $text));
$text = ($text == '' ? $url : $text);
$bTextUrl = ($text == $url);
$bShortUrl = (($this->allow['SHORT_ANCHOR'] ?? '') == 'Y');
$text = str_replace("\"", """, $text);
$postfix = "";
$pattern = "/([.,?!;]|!)$/" . BX_UTF_PCRE_MODIFIER;
if ($bTextUrl && preg_match($pattern, $url, $match))
{
$postfix = $match[1];
$url = preg_replace($pattern, '', $url);
$text = preg_replace($pattern, '', $text);
}
$url = preg_replace(
[
"/&/" . BX_UTF_PCRE_MODIFIER,
"/javascript:/i" . BX_UTF_PCRE_MODIFIER,
"/[" . chr(12) . "']/" . BX_UTF_PCRE_MODIFIER,
"/[/" . BX_UTF_PCRE_MODIFIER,
"/]/" . BX_UTF_PCRE_MODIFIER,
],
[
"&",
"java script: ",
"%27",
"[",
"]",
],
$url
);
if (mb_substr($url, 0, 1) != '/' && !preg_match("/^(" . $this->getAnchorSchemes() . "):/i" . BX_UTF_PCRE_MODIFIER, $url))
{
$url = 'http://' . $url;
}
$text = preg_replace(
["/&/i" . BX_UTF_PCRE_MODIFIER, "/javascript:/i" . BX_UTF_PCRE_MODIFIER],
["&", "javascript: "],
$text
);
if ($bShortUrl &&
mb_strlen($text) > $this->maxAnchorLength &&
preg_match("/^(" . $this->getAnchorSchemes() . "):\/\/(\S+)$/i" . BX_UTF_PCRE_MODIFIER, $text, $matches))
{
$uri_type = $matches[1];
$stripped = $matches[2];
$text = $uri_type . '://' . (mb_strlen($stripped) > $this->maxAnchorLength ?
mb_substr($stripped, 0, $this->maxAnchorLength - 10) . '...' . mb_substr($stripped, -10) :
$stripped
);
}
if ($this->anchorType === 'bbcode')
{
if ($url === $text)
{
$link = '[URL]' . $url . '[/URL]';
}
else
{
$link = '[URL=' . $url . ']' . $text . '[/URL]';
}
}
else
{
$url = $this->defended_tags(htmlspecialcharsbx($url, ENT_COMPAT, false));
if (strpos($text, "<