Version 3.4.6
This commit is contained in:
1 parent
e4478369d8
commit
b45ea0dffb
1568 files changed
+155104
-161665
No files matched your search
@@ -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 $!^&. Submitted in a post that is <p>$!^&</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 );
|
||||
|
||||
|
||||
Reference in new issue
Block a user