mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 04:32:01 +02:00
Fixes #4403 - Parsing of [code]. Test added.
This commit is contained in:
parent
dc29822e89
commit
46b6927447
@ -1496,7 +1496,7 @@ class e_parse
|
||||
{
|
||||
// Split each text block into bits which are either within one of the 'key' bbcodes, or outside them
|
||||
// (Because we have to match end words, the 'extra' capturing subpattern gets added to output array. We strip it later)
|
||||
$content = preg_split('#(\[(table|html|php|code|scode|hide).*?\[/(?:\\2)\])#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||
$content = preg_split('#(\[(table|html|php|code|scode|hide).*?\[\/(?:\\2)\])#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||
}
|
||||
|
||||
|
||||
@ -1519,25 +1519,13 @@ class e_parse
|
||||
|
||||
$opts = $saveOpts;
|
||||
|
||||
|
||||
// Have to have a good test in case a 'non-key' bbcode starts the block
|
||||
// - so pull out the bbcode parameters while we're there
|
||||
if(($parseBB !== false) && preg_match('#(^\[(table|html|php|code|scode|hide)(.*?)\])(.*?)(\[/\\2\]$)#is', $full_text, $matches))
|
||||
{
|
||||
// It's one of the 'key' bbcodes
|
||||
// Usually don't want 'normal' processing if its a 'special' bbcode
|
||||
$proc_funcs = false;
|
||||
// $matches[0] - complete block from opening bracket of opening tag to closing bracket of closing tag
|
||||
// $matches[1] - complete opening tag (inclusive of brackets)
|
||||
// $matches[2] - bbcode word
|
||||
// $matches[3] - parameter, including '='
|
||||
// $matches[4] - bit between the tags (i.e. text to process)
|
||||
// $matches[5] - closing tag
|
||||
// In case we decide to load a file
|
||||
|
||||
// $bbPath = e_CORE . 'bbcodes/';
|
||||
// $bbFile = strtolower(str_replace('_', '', $matches[2]));
|
||||
// $bbcode = '';
|
||||
// $className = '';
|
||||
$proc_funcs = false;
|
||||
$full_text = '';
|
||||
$code_text = $matches[4];
|
||||
// $parm = $matches[3] ? substr($matches[3], 1) : '';
|
||||
@ -1581,8 +1569,7 @@ class e_parse
|
||||
|
||||
case 'scode':
|
||||
case 'code' :
|
||||
$parseBB = false;
|
||||
$full_text = $this->parseBBCodes('['.$last_bbcode.']'.$code_text.'[/'.$last_bbcode.']', $postID);
|
||||
$full_text = $this->parseBBCodes($matches[0], $postID);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -5435,6 +5422,7 @@ class e_parse
|
||||
}
|
||||
|
||||
$text = str_replace(E_NL, $nl_replace, $text);
|
||||
|
||||
}
|
||||
|
||||
return $text;
|
||||
|
@ -458,10 +458,20 @@ while($row = $sql->fetch())
|
||||
'expected' => "<table class='table table-striped table-bordered bbcode-table'><tr>\n<td>cell</td>\n</tr></table>",
|
||||
),
|
||||
|
||||
4 => array(
|
||||
'text' => "Test\n[b]first line[/b][b]\nsecond line[/b]",
|
||||
'expected' => "Test<br /><strong class='bbcode bold bbcode-b'>first line</strong><strong class='bbcode bold bbcode-b'><br />second line</strong>",
|
||||
),
|
||||
|
||||
5 => array(
|
||||
'text' => "Test\n[code]1st [b]line[/b] of code[/code]\n[code]2nd line of code[/code]",
|
||||
'expected' => "Test<br /><pre class='prettyprint linenums code_highlight code-box bbcode-code' style='unicode-bidi: embed; direction: ltr'>1st [b]line[/b] of code</pre><pre class='prettyprint linenums code_highlight code-box bbcode-code' style='unicode-bidi: embed; direction: ltr'>2nd line of code</pre>",
|
||||
),
|
||||
|
||||
|
||||
);
|
||||
|
||||
foreach($tests as $var)
|
||||
foreach($tests as $index => $var)
|
||||
{
|
||||
$result = $this->tp->toHTML($var['text'], true);
|
||||
|
||||
@ -471,15 +481,13 @@ while($row = $sql->fetch())
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertEquals($var['expected'], $result);
|
||||
$this->assertEquals($var['expected'], $result, 'Test #'.$index.' failed.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testParseTemplateWithEnabledCoreShortcodes()
|
||||
{
|
||||
$needle = '<ul class="nav navbar-nav nav-main ml-auto">';
|
||||
|
Loading…
x
Reference in New Issue
Block a user