function op_decoration($string, $is_strip = false, $is_use_stylesheet = null, $is_html_tag_followup = true) { if (is_null($is_use_stylesheet)) { $is_use_stylesheet = true; if (sfConfig::get('sf_app') == 'mobile_frontend') { $is_use_stylesheet = false; } } return opWidgetFormRichTextareaOpenPNE::toHtml($string, $is_strip, $is_use_stylesheet, $is_html_tag_followup); }
<?php include_once dirname(__FILE__) . '/../../bootstrap/unit.php'; sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('pc_frontend', 'test', true)); include_once sfConfig::get('sf_lib_dir') . '/vendor/symfony/lib/helper/HelperHelper.php'; use_helper('Tag'); $t = new lime_test(27, new lime_output_color()); //------------------------------------------------------------ $t->diag('opWidgetFormRichTextareaOpenPNE::toHtml() non strip'); $patterns = array(array('<op:s>どーん</op:s>', '<span class="op_s">どーん</span>', 'Check default strike tag.'), array('<op:s>どどー<op>ん</op:s>', '<span class="op_s">どどー<op>ん</span>', 'Check strike tag with broken tag.'), array('<op:s>どどー', '<span class="op_s">どどー</span>', 'Check strike tag what is not having end tag.'), array('<op:a<op:i>', '<op:a<span class="op_i"></span>', 'Check italic tag with broken tag where is top.'), array('<op:i color="#333<op:i>">#333</op:i>', '<op:i color="#333<span class="op_i">">#333</span>', 'Check italic tag what have some broken tags.'), array('<op:font color="#333333">#333</op:font>', '<span class="op_font" style="color:#333333;">#333</span>', 'Check default color tag what have some broken tags.'), array('<op:tetetetetete0111111>', '<span class="op_tetetetetete0111111"></span>', 'Check undefined op tag.'), array('<op:i<br />><op:', '<op:i<br />><op:', 'Check broken tag witdh br tag.'), array('<op:font color="expression(alert(0))">Attack!</op:font>', '<span class="op_font" style="">Attack!</span>', 'Check color tag witdh CSRF Attack.')); foreach ($patterns as $pattern) { $t->is(opWidgetFormRichTextareaOpenPNE::toHtml($pattern[0], false, true, true), $pattern[1], $pattern[2]); } //------------------------------------------------------------ $t->diag('opWidgetFormRichTextareaOpenPNE::toHtml() strip'); $patterns2 = array(array('<op:s>どーん</op:s>', 'どーん', 'Check default strike tag.'), array('<op:s>どどー<op>ん</op:s>', 'どどー<op>ん', 'Check strike tag with broken tag.'), array('<op:s>どどー', 'どどー', 'Check strike tag what is not having end tag.'), array('<op:a<op:i>', '<op:a', 'Check italic tag with broken tag where is top.'), array('<op:i color="#333<op:i>">#333</op:i>', '<op:i color="#333">#333', 'Check italic tag what have some broken tags.'), array('<op:font color="#333">#333</op:font>', '#333', 'Check default color tag what have some broken tags.'), array('<op:tetetetetete0111111>', '', 'Check undefined op tag.'), array('<op:i<br />><op:', '<op:i<br />><op:', 'Check broken tag witdh br tag.'), array('<op:font color="expression(alert(0))">Attack!</op:font>', 'Attack!', 'Check color tag witdh CSRF Attack.')); foreach ($patterns2 as $pattern2) { $t->is(opWidgetFormRichTextareaOpenPNE::toHtml($pattern2[0], true, true, true), $pattern2[1], $pattern2[2]); } //------------------------------------------------------------ $t->diag('opWidgetFormRichTextareaOpenPNE::toHtml() followup'); $patterns3 = array(array('<op:s>どーん', '<span class="op_s">どーん</span>', 'Check default strike tag.'), array('<op:s>どどー<op>ん', '<span class="op_s">どどー<op>ん</span>', 'Check strike tag with broken tag.'), array('<op:s>どどー', '<span class="op_s">どどー</span>', 'Check strike tag what is not having end tag.'), array('<op:a<op:i>', '<op:a<span class="op_i"></span>', 'Check italic tag with broken tag where is top.'), array('<op:i color="#333<op:i>">#333', '<op:i color="#333<span class="op_i">">#333</span>', 'Check italic tag what have some broken tags.'), array('<op:font color="#333333">#333', '<span class="op_font" style="color:#333333;">#333</span>', 'Check default color tag what have some broken tags.'), array('<op:tetetetetete0111111>', '<span class="op_tetetetetete0111111"></span>', 'Check undefined op tag.'), array('<op:i><op:<op:i><op:i><op:i><op:333333>', '<span class="op_i"><op:<span class="op_i"><span class="op_i"><span class="op_i"><span class="op_333333"></span></span></span></span></span>', 'Check 5 open tags what have not close tag.'), array('<op:font color="expression(alert(0))">Attack!', '<span class="op_font" style="">Attack!</span>', 'Check color tag witdh CSRF Attack.')); foreach ($patterns3 as $pattern3) { $t->is(opWidgetFormRichTextareaOpenPNE::toHtml($pattern3[0], false, true, true), $pattern3[1], $pattern3[2]); }