1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-14 02:24:08 +02:00

Fixes #4346 - TinyMce parser issue. Hide side-panel help icon on legacy admin theme.

This commit is contained in:
Cameron
2021-02-05 18:31:54 -08:00
parent ddc53d00be
commit 2337b075a8
8 changed files with 224 additions and 90 deletions

View File

@@ -13,7 +13,7 @@
{
/** @var e_bbcode */
protected $bb;
protected e_bbcode $bb;
protected function _before()
{
@@ -47,12 +47,39 @@
{
}
*/
public function testHtmltoBBcode()
{
$text = '<h1 style="text-align: center;">Heading 1</h1>
<h2 style="text-align: right;">Heading 2</h2>
<h3 style="text-align: left;">Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<div style="background-color: #333; color: white; padding: 10px;">
<p>Paragraph.</p>
<table onclick="alert(1)">
<colgroup>
<col style="width:30%" />
<col style="width:70%" />
</colgroup>
<thead>
<tr><th>Column 1</th><th>Column 2</th></tr>
</thead>
<tbody>
<tr><td><a href="#">link</a></td><td></td></tr>
</tbody>
</table>
</div>';
$result = $this->bb->htmltoBbcode($text);
$expected = strip_tags($result);
$this->assertSame($expected, $result);
}
/*
public function testImgToBBcode()
{

View File

@@ -76,8 +76,10 @@ Plain text paragraph 3<br />';
/**
* Test parsing of input from user via TinyMce.
*/
public function testToBBcode()
public function testToDB()
{
$this->tm->setHtmlClass(e_UC_ADMIN);
$test_1 = '<ul>
<li>one<a class="bbcode bbcode-link" href="http://www.three.co.uk/"></a></li>
@@ -88,7 +90,7 @@ Plain text paragraph 3<br />';
<sup>2</sup>
';
$actual_1 = $this->tm->toBBcode($test_1);
$actual_1 = $this->tm->toDB($test_1);
$expected_1 = '[html]<ul>
<li>one<a class="bbcode bbcode-link" href="http://www.three.co.uk/"></a></li>
<li>two</li>
@@ -110,7 +112,7 @@ Plain text paragraph 3<br />';
$actual_2 = $this->tm->toBBcode($test_2);
$actual_2 = $this->tm->toDB($test_2);
$expected_2 = '[html]<p>[img class=bbcode-img-right&width=300]{e_MEDIA_IMAGE}2017-11/e107_about.png[/img]Some text</p>
<p>[img class=bbcode-img-left&width=600]{e_MEDIA_IMAGE}2017-11/e107_about.png[/img]Some other text</p>[/html]';
@@ -122,21 +124,120 @@ Plain text paragraph 3<br />';
}
function testParsingOfScriptTags()
/**
* Simulate TinyMce usage by a user without access to post HTML.
*/
function testToDBUser()
{
$text = "An example,<br />
<br />
Thank you for your purchase.<br />
Your order reference number is: #{ORDER_DATA: order_ref}<br />
<br />
<table class='table'>
<colgroup>
<col style='width:50%' />
<col style='width:50%' />
</colgroup>
<tr>
<th>Merchant</th>
<th>Customer</th>
</tr>
<tr>
<td>{ORDER_MERCHANT_INFO}</td>
<td>
<h4>Billing address</h4>
{ORDER_DATA: cust_firstname} {ORDER_DATA: cust_lastname}<br />
</td>
</tr>
</table>
<hr />";
global $_E107;
$_E107['phpunit'] = true; // enable the user of check_class();
$this->tm->setHtmlClass(e_UC_NOBODY);
$result = $this->tm->toDB($text);
$_E107['phpunit'] = false;
}
function testtoDBOnScriptTags()
{
$this->tm->setHtmlClass(e_UC_ADMIN);
// test parsing of scripts.
$string = '<p><script type="text/javascript" src="https://cdn.myscript.net/js/1.js" async></script></p>';
$result = $this->tm->toBBcode($string);
$result = $this->tm->toDB($string);
$this->assertSame('[html]'.$string.'[/html]', $result);
$result = $this->tm->toHTML($string);
$this->assertSame($string, $result);
}
public function testParsingofTable()
{
// -----------
$string = "Hello {ORDER_DATA: cust_firstname} {ORDER_DATA: cust_lastname},<br />
<br />
Thank you for your purchase.<br />
Your order reference number is: #{ORDER_DATA: order_ref}<br />
<br />
<table class='table'>
<colgroup>
<col style='width:50%' />
<col style='width:50%' />
</colgroup>
<tr>
<th>Merchant</th>
<th>Customer</th>
</tr>
<tr>
<td>{ORDER_MERCHANT_INFO}</td>
<td>
<h4>Billing address</h4>
{ORDER_DATA: cust_firstname} {ORDER_DATA: cust_lastname}<br />
{ORDER_DATA: cust_company}<br />
{ORDER_DATA: cust_address}<br />
{ORDER_DATA: cust_city} &nbsp;{ORDER_DATA: cust_state} &nbsp;{ORDER_DATA: cust_zip}<br />
{ORDER_DATA: cust_country}
<br />
<h4>Shipping address</h4>
{ORDER_DATA: ship_firstname} {ORDER_DATA: ship_lastname}<br />
{ORDER_DATA: ship_company}<br />
{ORDER_DATA: ship_address}<br />
{ORDER_DATA: ship_city} &nbsp;{ORDER_DATA: ship_state} &nbsp;{ORDER_DATA: ship_zip}<br />
{ORDER_DATA: ship_country}
</td>
</tr>
</table>";
$this->tm->setHtmlClass(254);
$result = $this->tm->toDB($string);
$this->assertSame('[html]'.$string.'[/html]', $result);
$result = $this->tm->toHTML($string);
$this->assertSame($string, $result);
}
@@ -145,7 +246,4 @@ Plain text paragraph 3<br />';
}