- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/web/dom/htmlparser.php
- Класс: BitrixMainWebDOMHtmlParser
- Вызов: HtmlParser::parseAttributes
protected function parseAttributes($text)
{
static $search = array(
"'&(quot|#34);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(amp|#38);'i",
);
static $replace = array(
""",
"<",
">",
"&",
);
$attributes = array();
if ($text !== "")
{
preg_match_all("/(?'name'[w-_:?&]+)(?'eq's*=s*)?(?(eq)(["'])(?'val'.*?)g{-2})/s", $text, $attrTmp);
if(strpos($text, "&") === false)
{
foreach($attrTmp['name'] as $i => $attrName)
{
$attributes[$attrName] = $attrTmp['val'][$i];
}
}
else
{
foreach($attrTmp['name'] as $i => $attrName)
{
$attributes[$attrName] = preg_replace($search, $replace, $attrTmp['val'][$i]);
}
}
}
return $attributes;
}