Version 3.4.6

This commit is contained in:
Neo committed 2025-12-19 00:40:53 -08:00
1 parent e4478369d8
commit b45ea0dffb
1568 files changed
+155104 -161665

No files matched your search

+59 -34
View File
@@ -3,7 +3,7 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* IP.Board v3.4.6
* HTML parsing core
* Last Updated: $Date: 2012-06-08 09:28:02 +0100 (Fri, 08 Jun 2012) $
* </pre>
@@ -18,12 +18,12 @@
*
* <code>
* $html = $editor->process( $_POST['Post'] );
*
*
* require( IPS_ROOT_PATH . 'sources/classes/text/parser.php' );
*
*
* $parser = new classes_text_parser();
* print $parser->HtmlToBBCode( '<strong>Moo!</strong>' );
*
*
* Prints:
* [b]Moo[/b]
* </code>
@@ -75,6 +75,12 @@ class classes_text_parser
*/
protected static $NoBBCodeAutoLinkify = false;
/**
* Do not process media tags while auto-linking.
* @var bool
*/
protected static $NoMediaAutoLinkify = false;
/**
* Constructor
*
@@ -146,7 +152,7 @@ class classes_text_parser
/**
* Display the HTML to IPB
*
*
* Notes:
* CODE: Need to convert _prettyXprint, _linenums _lang- into correct class names
* @param string HTML
@@ -167,7 +173,7 @@ class classes_text_parser
/* Remove disabled tags */
if ( ! self::$Perms['parseHtml'] )
{
{
$html = $this->removeDisabledTags( $html );
}
@@ -438,7 +444,7 @@ class classes_text_parser
/**
* Takes content from the editor and makes it lovely and clean for saving
*
*
* @param string $html
* @return string
*/
@@ -451,7 +457,7 @@ class classes_text_parser
/* always make sure CODE goes first */
foreach( array( 'codebox', 'code', 'xml', 'sql', 'html' ) as $tagName )
{
{
$editor = $this->codeToPre( $editor, $tagName );
}
@@ -666,7 +672,7 @@ class classes_text_parser
if ( count( $data['open'] ) > 1 && count( $data['close'] ) > 1 )
{
$text = $this->quoteToBlockquote( $text, true );
}
}
if( $inner )
{
@@ -789,10 +795,10 @@ class classes_text_parser
$bbcode = new $classToLoad();
if ( $this->isBBCode( $text ) )
{
{
$text = $bbcode->toHtml( $text );
}
return $text;
}
@@ -803,7 +809,7 @@ class classes_text_parser
* @since 3.4
*/
public function isBBCode( $string )
{
{
if ( $this->forceBbcode )
{
return true;
@@ -822,7 +828,7 @@ class classes_text_parser
/**
* Takes HTML (*not* display) and checks it for built in limits such as quote and IMG
*
*
* @param string $text
*/
public function testForParsingLimits( $text, $check=array('img', 'quote', 'emoticons', 'urls') )
@@ -1068,8 +1074,6 @@ class classes_text_parser
*/
public function parseBadWords( $text='' )
{
/* @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/report-center-bypass-word-filter-r40719 */
if( self::$Perms['memberData']['member_group_id'] AND !self::$Perms['memberData']['g_id'] )
{
@@ -1098,7 +1102,7 @@ class classes_text_parser
}
/* strip out URLs so replacements aren't made */
preg_match_all( '#((http|https|news|ftp)://(?:[^<>\)\[\"\s]+|[a-zA-Z0-9/\._\-!&\#;,%\+\?:=]+))#isu', $text, $matches );
preg_match_all( '#((http|https|news|ftp)://(?:[^<>\)\[\"\s]+|[a-zA-Z0-9/\._\-!&\#;,%\+\?:=]+))#is', $text, $matches );
foreach( $matches[0] as $m )
{
@@ -1152,16 +1156,28 @@ class classes_text_parser
// @see http://stackoverflow.com/questions/6531724/how-exactly-do-regular-expression-word-boundaries-work-in-php
// What we really want to look for is a non-word character on either side, so this works
// Bad word filter for $!^& becomes $!^&amp;. Submitted in a post that is <p>$!^&amp;</p> and </ is not a shift from non-word to word character
//changed by denchu 06062013 \P{L} is better and works when others not
$text = preg_replace( '/(^|\P{L})' . $r['type'] . '(\P{L}|$)/i', "\\1" . $replace . "\\2", $text );
if ( IPS_DOC_CHAR_SET == 'UTF-8' && IPSText::isUTF8( $text ) )
{
$text = preg_replace( '/(^|\W)' . $r['type'] . '(\W|$)/iu', "\\1" . $replace . "\\2", $text );
}
else
{
$text = preg_replace( '/(^|\W)' . $r['type'] . '(\W|$)/i', "\\1" . $replace . "\\2", $text );
}
/* I'd retest that for a dollar! */
if ( strstr( $r['type'], '$' ) )
{
$test = preg_replace( '#(\\\\)?\$#', '$', $r['type'] );
$text = preg_replace( '/(^|\P{L})' . preg_quote( $test ) . '(\P{L}|$)/i', "\\1" . $replace . "\\2", $text );
if ( DOC_IPS_CHAR_SET == 'UTF-8' && IPSText::isUTF8( $test ) )
{
$text = preg_replace( '/(^|\W)' . preg_quote( $test ) . '(\W|$)/iu', "\\1" . $replace . "\\2", $text );
}
else
{
$text = preg_replace( '/(^|\W)' . preg_quote( $test ) . '(\W|$)/i', "\\1" . $replace . "\\2", $text );
}
}
// }
@@ -1172,7 +1188,7 @@ class classes_text_parser
// 'ass' in 'class' kills css
//----------------------------
if( $r['type'] == 'ass' )
if( strtolower( $r['type'] ) == 'ass' )
{
$text = preg_replace( "/(?<!cl)" . $r['type'] . "/i", $replace, $text );
}
@@ -1203,7 +1219,7 @@ class classes_text_parser
/**
* Parse emoticons in text
*
* @param string $txt
* @param string $txt
* @return string $txt
*/
public function parseEmoticons( $txt )
@@ -1640,7 +1656,7 @@ class classes_text_parser
/**
* Strip images
*
*
* @param string
* @return string
*/
@@ -1653,7 +1669,7 @@ class classes_text_parser
/**
* Convert IMG codes into text smilies
*
*
* @param text $txt
* @return text $txt
*/
@@ -1672,7 +1688,7 @@ class classes_text_parser
continue;
}
/* This can shave a lot of loading time off of a site if there is a lot of large text being parsed,
/* This can shave a lot of loading time off of a site if there is a lot of large text being parsed,
especially if there are a lot of emoticons too */
if( strpos( $txt, $row['image'] ) === false )
{
@@ -1706,14 +1722,14 @@ class classes_text_parser
if ( !in_array( $tag, array_keys( $bbcodeCache ) ) )
{
$disabled[] = $tag;
}
}
}
foreach( $bbcodeCache as $bbcode )
{
/* Allowed this BBCode? */
if ( $bbcode['bbcode_sections'] != 'all' || $bbcode['bbcode_groups'] != 'all' )
{
{
$sections = explode( ',', $bbcode['bbcode_sections'] );
$groups = array_diff( explode( ',', $bbcode['bbcode_groups'] ), array( '' ) );
$mygroups = array( self::$Perms['memberData']['member_group_id'] );
@@ -1748,7 +1764,7 @@ class classes_text_parser
{
if ( $section == self::$Perms['parseArea'] )
{
$section_pass = true;
$section_pass = true;
}
}
}
@@ -1893,7 +1909,7 @@ class classes_text_parser
* @param int $pid
*/
public function buildQuoteTag( $content, $author='', $date='', $collapsed=0, $pid=0 )
{
{
$ops = array();
if ( $author )
@@ -1984,7 +2000,7 @@ class classes_text_parser
* @param array $brackets
*/
public function HtmlAllowedPreContents( $html, $tag, $brackets )
{
{
/* PRE: Fetch paired opening and closing tags */
$data = $this->getTagPositions( $html, $tag, $brackets );
@@ -2136,7 +2152,7 @@ class classes_text_parser
for( $i = 97; $i <= 122; $i++ )
{
$txt = str_replace( "&#" . $i . ";", chr($i), $txt );
}
}
//-----------------------------------------
// Go all loopy
@@ -2153,7 +2169,7 @@ class classes_text_parser
$caseModifier = empty($r['a_casesensitive']) ? 'i' : '';
$r['a_short'] = preg_quote( $r['a_short'], "/" );
$txt = preg_replace_callback( '/(^|'.$wordModifier.')(' . $r['a_short'] . ')('.$wordModifier.'|$)/' . $caseModifier, array( $this, '_replaceAcronym' ), $txt );
$txt = preg_replace_callback( '/(^|\b|\W)(' . $r['a_short'] . ')(\b|\W|$)/' . $caseModifier, array( $this, '_replaceAcronym' ), $txt );
}
}
@@ -2426,6 +2442,15 @@ class classes_text_parser
$this->emoticon_count++;
$this->emoticon_alts[] = array( "#EMO_ALT_{$this->emoticon_count}#", $_emoCode );
/**
* <#EMO_DIR#> can end up not replaced at this point in specific situations.
* @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/emoticons-bug-with-pm-archives-r42796
*/
if ( strstr( $this->settings['emoticons_url'], '<#EMO_DIR#>' ) AND $this->registry->output->skin['set_emo_dir'] )
{
$this->settings['emoticons_url'] = str_replace( '<#EMO_DIR#>', $this->registry->output->skin['set_emo_dir'], $this->settings['emoticons_url'] );
}
//-----------------------------------------
// Return
@@ -2493,7 +2518,7 @@ class classes_text_parser
}
/* Fetch paired opening and closing tags */
$data = $this->getTagPositions( $content, $tag, array( '[', ']') );
$data = $this->getTagPositions( $content, $tag, array( '[', ']' ) );
if ( is_array( $data ) && count( $data ) )
{
@@ -2513,7 +2538,7 @@ class classes_text_parser
$_origLen = strlen( $slice );
if ( $passLevel == 2 )
{
{
//* No linkify */
preg_match_all( '#<a(?:[^>]+?)href=["\']([^"\']+?)["\']([^>]+?)?>(.+?)(</a>|$)#is', $slice, $urlMatches );
@@ -3,7 +3,7 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* IP.Board v3.4.6
* BBCode parsing core - common methods
* Last Updated: $Date: 2012-06-08 09:28:02 +0100 (Fri, 08 Jun 2012) $
* </pre>
@@ -420,8 +420,14 @@ class class_text_parser_bbcode extends classes_text_parser
$txt = str_replace( '</div><br />', '</div>', $txt );
$txt = str_replace( '</blockquote><br />', '</blockquote>', $txt );
// Don't auto-link media.
parent::$NoMediaAutoLinkify = true;
$txt = $this->_autoLinkUrls( $txt );
// Reset
parent::$NoMediaAutoLinkify = false;
return $txt;
}
@@ -1289,7 +1295,7 @@ class class_text_parser_bbcode extends classes_text_parser
$txt = $this->_autoLinkUrls( $txt );
}
preg_match_all( '#<a\s+?(?:[^>]*?)href=["\']([^"\']+?)?["\']([^>]*?)?>(.+?)</a>#isu', $txt, $urlMatches );
preg_match_all( '#<a\s+?(?:[^>]*?)href=["\']([^"\']+?)?["\']([^>]*?)?>(.+?)</a>#is', $txt, $urlMatches );
/* Finish up URLs and such */
for( $i = 0 ; $i < count( $urlMatches[0] ) ; $i++ )
@@ -1381,8 +1387,7 @@ class class_text_parser_bbcode extends classes_text_parser
*/
if ( ( empty( $this->settings['__noTruncateUrl'] ) ) and IPSText::mbstrlen( $text ) > 38 && ( ! preg_match( '#&\#([0-9]{2,4})#i', $text ) ) and ( substr( $text, 0, 7 ) == 'http://' or substr( $text, 0, 8 ) == 'https://' ) )
{
$text = htmlspecialchars( IPSText::mbsubstr( $this->utf8_urldecode( $text ) , 0, 20 ) ) . '...' . htmlspecialchars( IPSText::mbsubstr($this->utf8_urldecode( $text ) , -15 ) );
//$text = htmlspecialchars( IPSText::mbsubstr( html_entity_decode( urldecode( $text ) ), 0, 20 ) ) . '...' . htmlspecialchars( IPSText::mbsubstr( html_entity_decode( urldecode( $text ) ), - 15 ) );
$text = htmlspecialchars( IPSText::mbsubstr( html_entity_decode( urldecode( $text ) ), 0, 20 ) ) . '...' . htmlspecialchars( IPSText::mbsubstr( html_entity_decode( urldecode( $text ) ), - 15 ) );
}
// -----------------------------------------
@@ -1432,14 +1437,6 @@ class class_text_parser_bbcode extends classes_text_parser
}
return $txt;
}
function utf8_urldecode($str)
{
$str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
$str = mb_convert_encoding($str, IPS_DOC_CHAR_SET);
return html_entity_decode($str,null,IPS_DOC_CHAR_SET);
}
/**
@@ -1559,6 +1556,11 @@ class class_text_parser_bbcode extends classes_text_parser
{
return $matches[0];
}
if ( $matches[1] == ']' )
{
return $matches[0];
}
if ( isset( $matches[4] ) AND stristr( $matches[4], '</a>' ) )
{
@@ -1591,7 +1593,7 @@ class class_text_parser_bbcode extends classes_text_parser
}
/* Is this a media URL? */
if( $this->settings['bbcode_automatic_media'] and isset( $this->_bbcodes['media'] ) and ( $this->_bbcodes['media']['bbcode_sections'] == 'all' or in_array( parent::$Perms['parseArea'], explode( ',', $this->_bbcodes['media']['bbcode_sections'] ) ) ) )
if( ! parent::$NoMediaAutoLinkify and $this->settings['bbcode_automatic_media'] and isset( $this->_bbcodes['media'] ) and ( $this->_bbcodes['media']['bbcode_sections'] == 'all' or in_array( parent::$Perms['parseArea'], explode( ',', $this->_bbcodes['media']['bbcode_sections'] ) ) ) )
{
$media = $this->cache->getCache( 'mediatag' );
@@ -2,7 +2,7 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* IP.Board v3.4.6
* IP.Content custom bbcode
* Last Updated: $Date: 2012-06-01 13:11:08 -0400 (Fri, 01 Jun 2012) $
* </pre>
@@ -2,7 +2,7 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* IP.Board v3.4.6
* Custom bbcode plugin interfaces
* Last Updated: $Date: 2012-05-24 16:33:36 +0100 (Thu, 24 May 2012) $
* </pre>
@@ -12,13 +12,13 @@
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 10790 $
* @version $Rev: 10790 $
*/
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* IP.Board v3.4.6
* BBCode parser: default custom bbcodes: img, quote, list, size, member, media, url, snapback
* Last Updated: $Date: 2012-05-24 16:33:36 +0100 (Thu, 24 May 2012) $
* </pre>
@@ -28,7 +28,7 @@
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 10790 $
* @version $Rev: 10790 $
*
*/
@@ -39,7 +39,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var integer
*/
*/
protected $cur_pos = 0;
/**
@@ -47,7 +47,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var integer
*/
*/
protected $end_pos = 0;
/**
@@ -55,7 +55,7 @@ class bbcode_parent_main_class
*
* @access public
* @var string
*/
*/
public $error = '';
/**
@@ -63,7 +63,7 @@ class bbcode_parent_main_class
*
* @access public
* @var string
*/
*/
public $warning = '';
/**
@@ -71,7 +71,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var integer
*/
*/
protected $_bbcode = array();
/**
@@ -79,7 +79,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var object
*/
*/
protected $registry;
/**
@@ -87,7 +87,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var object
*/
*/
protected $DB;
/**
@@ -95,7 +95,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var object
*/
*/
protected $settings;
/**
@@ -103,7 +103,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var object
*/
*/
protected $request;
/**
@@ -111,7 +111,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var object
*/
*/
protected $lang;
/**
@@ -119,7 +119,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var object
*/
*/
protected $member;
protected $memberData;
@@ -128,7 +128,7 @@ class bbcode_parent_main_class
*
* @access protected
* @var object
*/
*/
protected $cache;
protected $caches;
@@ -283,7 +283,7 @@ class bbcode_plugin_sharedmedia extends bbcode_parent_main_class
$app = trim( $matches[2] );
$plugin = trim( $matches[3] );
if( !$txt OR !$app OR !$plugin )
if( !$txt OR !$app OR ! IPSLib::appIsInstalled( $app ) OR !$plugin )
{
return '';
}
@@ -326,7 +326,7 @@ class bbcode_plugin_sharedmedia extends bbcode_parent_main_class
$plugin = trim( $matches[3] );
$_orig = $txt;
if( !$txt OR !$app OR !$plugin )
if( !$txt OR !$app OR ! IPSLib::appIsInstalled( $app ) OR !$plugin )
{
return '';
}
@@ -933,7 +933,7 @@ class bbcode_plugin_size extends bbcode_parent_main_class
*
* @access protected
* @var array
*/
*/
protected $font_sizes = array( 1 => 8,
2 => 10,
3 => 12,
@@ -1259,7 +1259,7 @@ class bbcode_plugin_url extends bbcode_parent_main_class
}
//-----------------------------------------
// Need this because HTML on converts the
// Need this because HTML on converts the
// entities back to quote/apos
//-----------------------------------------
@@ -1278,7 +1278,7 @@ class bbcode_plugin_url extends bbcode_parent_main_class
$txt = substr_replace( $txt, $new_content, $this->cur_pos + $open_length + 1, ($end_pos - ($this->cur_pos + $open_length + 1 ) ) );
}
else if( substr( $txt, $this->cur_pos + $open_length, 1 ) == "'" )
{
{
/* Skip the bbocde if there is mroe than 2 quotes. Bug #21161 */
if( strlen( substr( $txt, $this->cur_pos, stripos( $txt, ']', $this->cur_pos ) - $this->cur_pos ) ) < 1 OR ( substr_count( $txt, "'", $this->cur_pos, strlen( substr( $txt, $this->cur_pos, stripos( $txt, ']', $this->cur_pos ) - $this->cur_pos ) ) ) ) > 2 )
{
@@ -1350,7 +1350,7 @@ class bbcode_plugin_url extends bbcode_parent_main_class
//-----------------------------------------
// If this is a single tag, that's it
// @link: http://forums.invisionpower.com/index.php?autocom=tracker&showissue=11909
// @link: http://forums.invisionpower.com/index.php?autocom=tracker&showissue=11909
//-----------------------------------------
if( $_content OR $_content === '0' )
@@ -1414,7 +1414,7 @@ class bbcode_plugin_url extends bbcode_parent_main_class
else if( substr( $option, 0, 1 ) == "'" )
{
$option = substr( $option, 1 );
}
}
else if( substr( $option, 0, 1 ) == '"' )
{
$option = substr( $option, 1 );
@@ -1431,7 +1431,7 @@ class bbcode_plugin_url extends bbcode_parent_main_class
else if( substr( $option, -1 ) == "'" )
{
$option = substr( $option, 0, -1 );
}
}
else if( substr( $option, -1 ) == '"' )
{
$option = substr( $option, 0, -1 );
@@ -1484,7 +1484,7 @@ class bbcode_plugin_url extends bbcode_parent_main_class
{
$this->warning = 'domain_not_allowed';
return $option;
}
}
/* If this is just converting to HTML and not display, return the URL as
* filters and such are tested on display */
@@ -1847,6 +1847,7 @@ class bbcode_plugin_code extends bbcode_parent_main_class
$content = trim( $content );
$content = preg_replace( '#(<br(?:[^>]+?)?>)#i', '', $content );
$content = trim( $content );
$content = str_replace( '<!-preserve.newline-->', "\n", $content );
@@ -2632,6 +2633,9 @@ class bbcode_plugin_member extends bbcode_parent_main_class
/* Re-encode single quote: @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/apostrophes-and-member-bbcode-r41425 */
$_option = str_replace( "'", '&#39;', $_option );
/* Re-encode exclamation points: @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/username-is-now-showing-with-member-tag-if-contains-r43032 */
$_option = str_replace( "!", '&#33;', $_option );
$existing = $this->cache->getCache( '_tmp_bbcode_members', false );
$existing = is_array($existing) ? $existing : array();
@@ -2645,6 +2649,10 @@ class bbcode_plugin_member extends bbcode_parent_main_class
{
$_content = $this->_buildOutput( $existing[ $_option ] );
}
else
{
$_content = $_option;
}
//-----------------------------------------
// If this is a single tag, that's it
@@ -3,7 +3,7 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* IP.Board v3.4.6
* Text Parsing: HTML
* Last Updated: $Date: 2012-06-08 09:28:02 +0100 (Fri, 08 Jun 2012) $
* </pre>
@@ -3,7 +3,7 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* IP.Board v3.4.6
* Text Parsing: LEGACY CR..STUFF
* Last Updated: $Date: 2012-06-08 09:28:02 +0100 (Fri, 08 Jun 2012) $
* </pre>