cashloveyou
@cashloveyou
Хороший чел

Что может настырно резать Iframe?

Добрый день при публикации поста , нагло обрезается тег iframe , публикуется пост через обычную textarea
в самой функции add_feed
нашел такое
$content = sanitizeText($content);

Сама функция sanitizetext
if (!function_exists('sanitizeText')) {
    function sanitizeText($string, $limit = false, $output = false) {
        if (!is_string($string)) return $string;
        $lawed_config = array(
            'safe' => 1,
            'deny_attribute' => 'id, style, class'
        );
        $string = lawedContent($string, $lawed_config);//great one
        $string = trim($string);
        //$string = htmlspecialchars($string, ENT_QUOTES);

        $string = str_replace('&#', '&#',$string);
        $string = str_replace('&', '&',$string);
		$string = preg_match('/src="([^"]+)"/', $string, $match);

        if ($limit) {
            $string = substr($string, 0, $limit);
        }
        return $string;
    }

}


Еще такие подозрительные функции

function format_output_text($content) {
    $content = str_replace("\r\n", '<br />',$content);
    $content = str_replace("\n", '<br />',$content);
    $content = str_replace("\r", '<br />',$content);
    $content = stripslashes($content);
    $content = autoLinkUrls($content);
    if ($content) $content = fire_hook('filter.content', $content);
    $content = ($content);
    $lawed_config = array(
        'safe' => 1,
        'deny_attribute' => 'id, style, class'
    );
    $content = lawedContent($content, $lawed_config);
    //replace bad words
    $badWords = config('ban_filters_words', '');
    if ($badWords) {
        $badWords = explode(',', $badWords);
        foreach($badWords as $word) {
            $content = str_replace($word, '***', $content);
        }
    }

    return $content;
}


ииии

function output_text($content, $options = array('html' => true, 'length' => 500, 'more' => true)) {
    /**
     * @var $html
     * @var $length
     * @var $more
     */
    extract($options);
    $content = format_output_text($content);
    $tContent = $content;
    $original = $content;

    if (is_rtl($content)) {
        $content = "<span style='direction: rtl;text-align: right;display: block'>{$content}</span>";
    }
    //too much text solution
    $id = md5($tContent.time());
    $result = "<span id='{$id}' style='font-weight: normal !important'>";
    if ($more === true) {
        if (strlen(preg_replace('/\s+/', ' ', strip_tags($tContent, '<br>'))) > $length) {
            $result .= "<span class='text-full' style='display: none;font-weight: normal'>{$content}</span>";
            $tContent = format_output_text(str_limit($tContent, $length, array('ending' => '...', 'html' => $html)));
            if (is_rtl($tContent)) $tContent = "<span style='direction: rtl;text-align: right;display:block'>{$tContent}</span>";
            $result .= "<span style='font-weight: normal !important'>".$tContent."</span>";
            $result .= '<a href="" onclick=\'return read_more(this, "'.$id.'")\'>'.lang('read-more').'</a>';
        } else {
            $result .= $content;
        }
    } elseif($more) {
        $result .= "<span class='text-full' style='display: none;font-weight: normal'>{$content}</span>";
        $tContent = format_output_text(str_limit($tContent, $length, array('ending' => '...', 'html' => $html)));
        if (is_rtl($tContent)) $tContent = "<span style='direction: rtl;text-align: right;display:block'>{$tContent}</span>";
        $result .= "<span style='font-weight: normal !important'>".$tContent."</span>";
        $result .= '<a href="'.$more.'" ajax="true">'.lang('read-more').'</a>';
    } else {
        $result .= $content;
    }

    $result .= "</span>";
    if (config('enable-text-translation', false) and !empty($original) and !isEnglish($original)) {
        $trans = lang('see-translation');
        $result .= "<div id='{$id}-translation' class='non-translated'><input name='text' type='hidden' value='{$original}'/><button data-id='{$id}' onclick='return translateText(this)'>{$trans}</button></div>";
    }
    return $result;
}


Как можно избавиться от обрезки тега
  • Вопрос задан
  • 148 просмотров
Пригласить эксперта
Ответы на вопрос 1
KorniloFF
@KorniloFF
Работаю по font-end / JS
if (strlen(preg_replace('/\s+/', ' ', strip_tags($tContent, '<br>'))) > $length)

Замените на
if (strlen(preg_replace('/\s+/', ' ', strip_tags($tContent, '<br><iframe>'))) > $length)
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы