diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index 5a90ecc6e..ab9abf503 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -763,14 +763,13 @@ class e_bbcode if(strpos($qr['src'],'http')!==0 && empty($qr['w']) && empty($qr['aw'])) { - $qr['w'] = $img['width']; - $qr['h'] = $img['height']; + $qr['w'] = varset($img['width']); + $qr['h'] = varset($img['height']); } $qr['ebase'] = true; - if(!empty($img['class'])) { $tmp = explode(" ",$img['class']); @@ -797,7 +796,7 @@ class e_bbcode } - if($this->resizeWidth() === (int) $img['width']) + if($this->resizeWidth() === (int) varset($img['width'])) { unset($img['width']); } diff --git a/e107_plugins/tinymce4/plugins/e107/parser.php b/e107_plugins/tinymce4/plugins/e107/parser.php index 440616182..9e10aabc7 100644 --- a/e107_plugins/tinymce4/plugins/e107/parser.php +++ b/e107_plugins/tinymce4/plugins/e107/parser.php @@ -183,10 +183,12 @@ TEMPL; exit; } + $content = html_entity_decode($content); $text = !empty($content) ? "[html]".$content."[/html]" : ''; // Add the tags before saving to DB. } else // User doesn't have HTML access - bbcode Mode. { + $content = html_entity_decode($content); $text = e107::getBB()->htmltoBBcode($content); // not reliable enough yet. } diff --git a/e107_plugins/tinymce4/plugins/e107/plugin.js b/e107_plugins/tinymce4/plugins/e107/plugin.js index 2b9841217..446b8f66a 100644 --- a/e107_plugins/tinymce4/plugins/e107/plugin.js +++ b/e107_plugins/tinymce4/plugins/e107/plugin.js @@ -202,8 +202,12 @@ _e107_html2bbcode : function(s, url) { s = tinymce.trim(s); - // return s; - + if(s === '') + { + return ''; + } + // console.log('html2bbcode '+ s); + var p = $.ajax({ type: "POST", url: url + "/parser.php", @@ -228,9 +232,13 @@ _e107_bbcode2html : function(s, url) { s = tinymce.trim(s); - // FIXME mod-security might block the ajax call below with Rules: 942230, 949110, 980130 - reason yet unknown. + if(s === '') + { + return ''; + } - // return s; + // FIXME mod-security might block the ajax call below with Rules: 942230, 949110, 980130 - reason yet unknown. + // console.log('bbcode2html '+ s); var p = $.ajax({ type: "POST", diff --git a/e107_tests/tests/unit/e_bbcodeTest.php b/e107_tests/tests/unit/e_bbcodeTest.php index 7ac9af7a2..e821e0c8c 100644 --- a/e107_tests/tests/unit/e_bbcodeTest.php +++ b/e107_tests/tests/unit/e_bbcodeTest.php @@ -79,12 +79,35 @@ $this->assertSame($expected, $result); } -/* + public function testImgToBBcode() { - } + $tests = [ + 0 => [ + 'html' => '
[img title=test]{e_MEDIA_IMAGE}2021-10/test.jpg[/img]
' + ], + /* 1 => [ + 'html' => '[img title=test]{e_MEDIA_IMAGE}2021-10/test.jpg[/img]
' + ],*/ + + + + ]; + + + foreach($tests as $count => $t) + { + $actual = $this->bb->imgToBBcode($t['html']); + $this->assertSame($t['expected'], $actual, 'Test '.$count.' failed'); + + } + + } +/* public function testResizeHeight() { diff --git a/e107_tests/tests/unit/plugins/e107TinyMceParserTest.php b/e107_tests/tests/unit/plugins/e107TinyMceParserTest.php index e996c3ddb..01e2ed9ef 100644 --- a/e107_tests/tests/unit/plugins/e107TinyMceParserTest.php +++ b/e107_tests/tests/unit/plugins/e107TinyMceParserTest.php @@ -120,8 +120,15 @@ Plain text paragraph 3Nikdy nehovor, že niečo nejde, pretože sa vždy nájde blbec, čo to urobí.
"; + $actual_3 = $this->tm->toDB($test_3); + $expected_3 = "[html]Nikdy nehovor, že niečo nejde, pretože sa vždy nájde blbec, čo to urobí.
[/html]"; + $this->assertEquals($expected_3, $actual_3); + $result3 = $this->tm->toHTML($actual_3); + $this->assertEquals($test_3, $result3); + } /** @@ -213,14 +220,14 @@ Plain text paragraph 3