1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-29 10:50:25 +02:00

Null checks for e107TinyMceParserTest

- FIX: Do not redefine e_ADMIN_AREA in parser.php
- FIX: Null checks for e107TinyMceParser
- FIX: Array type check for e_bbcode::imgToBBcode()
- FIX: Optional query string in e_parse::thumbUrlDecode()
- FIX: Don't redefine TINYMCE_UNIT_TEST
This commit is contained in:
Nick Liu
2020-01-17 19:45:59 +01:00
parent c604b3019c
commit b2bd6763de
4 changed files with 17 additions and 6 deletions

View File

@@ -735,6 +735,7 @@ class e_bbcode
print_a($arr);
}
$arr['img'] = isset($arr['img']) && is_array($arr['img']) ? $arr['img'] : [];
foreach($arr['img'] as $img)
{
if(/*substr($img['src'],0,4) == 'http' ||*/ strpos($img['src'], e_IMAGE_ABS.'emotes/')!==false) // dont resize external images or emoticons.

View File

@@ -2914,7 +2914,7 @@ class e_parse extends e_parser
*/
function thumbUrlDecode($src)
{
list($url,$qry) = explode("?",$src);
list($url,$qry) = array_pad(explode("?",$src), 2, null);
$ret = array();

View File

@@ -19,7 +19,7 @@ $_E107['no_menus'] = true;
$_E107['no_forceuserupdate'] = true;
$_E107['no_maintenance'] = true;
define('e_ADMIN_AREA', true);
if (!defined('e_ADMIN_AREA')) define('e_ADMIN_AREA', true);
if(!defined('TINYMCE_DEBUG') && !defined('TINYMCE_UNIT_TEST'))
{
require_once("../../../../class2.php");
@@ -42,6 +42,9 @@ class e107TinyMceParser
*/
function __construct()
{
$_POST['mode'] = isset($_POST['mode']) ? $_POST['mode'] : 'tohtml';
$_POST['content'] = isset($_POST['content']) ? $_POST['content'] : '';
$html = '';
if(defined('TINYMCE_DEBUG') || defined('TINYMCE_UNIT_TEST'))
@@ -70,7 +73,6 @@ class e107TinyMceParser
TEMPL;
}
$_POST['content'] = $text;
$_POST['mode'] = 'tohtml';
}
else
{
@@ -119,7 +121,7 @@ TEMPL;
$content = stripslashes($content);
// $content = e107::getBB()->htmltoBBcode($content); //XXX This breaks inserted images from media-manager. :/
e107::getBB()->setClass($_SESSION['media_category']);
e107::getBB()->setClass($this->getMediaCategory());
if(check_class($pref['post_html'])) // raw HTML within [html] tags.
{
@@ -197,7 +199,7 @@ TEMPL;
$pref = e107::getPref();
// $tp = e107::getParser();
e107::getBB()->setClass($_SESSION['media_category']);
e107::getBB()->setClass($this->getMediaCategory());
$content = stripslashes($content);
@@ -231,6 +233,14 @@ TEMPL;
}
/**
* @return mixed|null
*/
private function getMediaCategory()
{
return isset($_SESSION['media_category']) ? $_SESSION['media_category'] : null;
}

View File

@@ -17,7 +17,7 @@
protected function _before()
{
define('TINYMCE_UNIT_TEST', true);
@define('TINYMCE_UNIT_TEST', true);
require_once(e_PLUGIN."tinymce4/plugins/e107/parser.php");
try
{