Small fixes for addHtml.

Adding some HTML Entities to the test for addHTML
This commit is contained in:
Brandon Skrtich 2014-06-09 15:17:40 -06:00
parent 4c04071fd5
commit d17a806305
2 changed files with 13 additions and 2 deletions

View File

@ -42,9 +42,14 @@ class Html
* which could be applied when such an element occurs in the parseNode function.
*/
// Preprocess: remove all line ends, decode HTML entity, and add body tag for HTML fragments
// Preprocess: remove all line ends, decode HTML entity,
// fix ampersand and angle brackets and add body tag for HTML fragments
$html = str_replace(array("\n", "\r"), '', $html);
$html = html_entity_decode($html);
$html = str_replace(array('<', '>', '&'), array('_lt_', '_gt_', '_amp_'), $html);
$html = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
$html = str_replace('&', '&', $html);
$html = str_replace(array('_lt_', '_gt_', '_amp_'), array('<', '>', '&'), $html);
if ($fullHTML === false) {
$html = '<body>' . $html . '</body>';
}

View File

@ -60,6 +60,12 @@ class HtmlTest extends \PHPUnit_Framework_TestCase
$content .= '<table><tr><th>Header</th><td>Content</td></tr></table>';
$content .= '<ul><li>Bullet</li><ul><li>Bullet</li></ul></ul>';
$content .= '<ol><li>Bullet</li></ol>';
$content .= "'Single Quoted Text'";
$content .= '"Double Quoted Text"';
$content .= '& Ampersand';
$content .= '&lt;&gt;&ldquo;&lsquo;&rsquo;&laquo;&raquo;&lsaquo;&rsaquo;';
$content .= '&amp;&bull;&deg;&hellip;&trade;&copy;&reg;&mdash;';
$content .= '&ndash;&nbsp;&emsp;&ensp;&sup2;&sup3;&frac14;&frac12;&frac34;';
Html::addHtml($section, $content);
}
}