[pcre-dev] [Bug 1187] Pcre 8.21 issue with Vbulletin

Startseite
Nachricht löschen
Autor: kotkerk
Datum:  
To: pcre-dev
Betreff: [pcre-dev] [Bug 1187] Pcre 8.21 issue with Vbulletin
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1187

kotkerk <kotkerk@???> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED





--- Comment #4 from kotkerk <kotkerk@???> 2011-12-29 13:50:42 ---
bug exists in all vBulletin forms
after posting, message text is parsed by vBulletin functions:
convert_url_to_bbcode($messagetext)
and
convert_url_to_bbcode_callback($messagetext, $prepend)
==
that functions use PCRE
preg_replace
preg_quote

vBulletin 3.8.x
==

/**
* Converts URLs in text to bbcode links
*
* @param        string  message text
*
* @return       string
*/
function convert_url_to_bbcode($messagetext)
{
        global $vbulletin;


        // areas we should attempt to skip auto-parse in
        $skiptaglist = 'url|email|code|php|html|noparse';


        if (!isset($vbulletin->bbcodecache))
        {
                $vbulletin->bbcodecache = array();


                $bbcodes = $vbulletin->db->query_read_slave("
                        SELECT *
                        FROM " . TABLE_PREFIX . "bbcode
                ");
                while ($customtag = $vbulletin->db->fetch_array($bbcodes))
                {
                        $vbulletin->bbcodecache["$customtag[bbcodeid]"] =
$customtag;
                }
        }


        foreach ($vbulletin->bbcodecache AS $customtag)
        {
                if (intval($customtag['options']) &
$vbulletin->bf_misc['bbcodeoptions']['stop_parse'] OR
intval($customtag['options']) &
$vbulletin->bf_misc['bbcodeoptions']['disable_urlconversion'])
                {
                        $skiptaglist .= '|' .
preg_quote($customtag['bbcodetag'], '#');
                }
        }


        ($hook = vBulletinHook::fetch_hook('url_to_bbcode')) ? eval($hook) :
false;


        return preg_replace(
                '#(^|\[/(' . $skiptaglist . ')\])(.*(\[(' . $skiptaglist .
')|$))#siUe',
                "convert_url_to_bbcode_callback('\\3', '\\1')",
                $messagetext
        );
}
==============


/**
* Callback function for convert_url_to_bbcode
*
* @param        string  Message text
* @param        string  Text to prepend
*
* @return       string
*/
function convert_url_to_bbcode_callback($messagetext, $prepend)
{
        global $vbulletin;


        // the auto parser - adds [url] tags around neccessary things
        $messagetext = str_replace('\"', '"', $messagetext);
        $prepend = str_replace('\"', '"', $prepend);


        static $urlSearchArray, $urlReplaceArray, $emailSearchArray,
$emailReplaceArray;
        if (empty($urlSearchArray))
        {
                $taglist =
'\[b|\[i|\[u|\[left|\[center|\[right|\[indent|\[quote|\[highlight|\[\*' .


'|\[/b|\[/i|\[/u|\[/left|\[/center|\[/right|\[/indent|\[/quote|\[/highlight';

                foreach ($vbulletin->bbcodecache AS $customtag)
                {
                        if (!(intval($customtag['options']) &
$vbulletin->bf_misc['bbcodeoptions']['disable_urlconversion']))
                        {
                                $customtag_quoted =
preg_quote($customtag['bbcodetag'], '#');
                                $taglist .= '|\[' . $customtag_quoted . '|\[/'
. $customtag_quoted;
                        }
                }


                ($hook = vBulletinHook::fetch_hook('url_to_bbcode_callback')) ?
eval($hook) : false;


                $urlSearchArray = array(
                        '#(^|(?<=[^_a-z0-9-=\]"\'/@]|(?<=' . $taglist .
')\]))((https?|ftp|gopher|news|telnet)://|www\.)((\[(?!/)|[^\s[^$`"{}<>])+)(?!\[/url|\[/img)(?=[,.!\')]*(\)\s|\)$|[\s[]|$))#siU'
                );


                $urlReplaceArray = array(
                        "[url]\\2\\4[/url]"
                );


                $emailSearchArray = array(
                        '/([
\n\r\t])([_a-z0-9-+]+(\.[_a-z0-9-+]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,6}))/si',


'/^([_a-z0-9-+]+(\.[_a-z0-9-+]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,6}))/si'
                );


                $emailReplaceArray = array(
                        "\\1[email]\\2[/email]",
                        "[email]\\0[/email]"
                );
        }


        $text = preg_replace($urlSearchArray, $urlReplaceArray, $messagetext);
        if (strpos($text, "@"))
        {
                $text = preg_replace($emailSearchArray, $emailReplaceArray,
$text);
        }


        return $prepend . $text;
}
===========



--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email