Merge branch 'MDL-50868-master' of git://github.com/jethac/moodle

This commit is contained in:
Dan Poltawski 2015-07-28 12:10:55 +01:00
commit dbceb531a7
2 changed files with 19 additions and 1 deletions

View File

@ -567,4 +567,19 @@ EXPECTED;
$this->assertSame($expected, strip_pluginfile_content($source)); $this->assertSame($expected, strip_pluginfile_content($source));
} }
public function test_purify_html_ruby() {
$this->resetAfterTest();
$ruby =
"<p><ruby><rb>京都</rb><rp>(</rp><rt>きょうと</rt><rp>)</rp></ruby>は" .
"<ruby><rb>日本</rb><rp>(</rp><rt>にほん</rt><rp>)</rp></ruby>の" .
"<ruby><rb>都</rb><rp>(</rp><rt>みやこ</rt><rp>)</rp></ruby>です。</p>";
$illegal = '<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>';
$cleaned = purify_html($ruby . $illegal);
$this->assertEquals($ruby, $cleaned);
}
} }

View File

@ -1705,7 +1705,7 @@ function purify_html($text, $options = array()) {
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$config->set('HTML.DefinitionID', 'moodlehtml'); $config->set('HTML.DefinitionID', 'moodlehtml');
$config->set('HTML.DefinitionRev', 2); $config->set('HTML.DefinitionRev', 3);
$config->set('Cache.SerializerPath', $cachedir); $config->set('Cache.SerializerPath', $cachedir);
$config->set('Cache.SerializerPermissions', $CFG->directorypermissions); $config->set('Cache.SerializerPermissions', $CFG->directorypermissions);
$config->set('Core.NormalizeNewlines', false); $config->set('Core.NormalizeNewlines', false);
@ -1744,6 +1744,9 @@ function purify_html($text, $options = array()) {
$def->addElement('algebra', 'Inline', 'Inline', array()); // Algebra syntax, equivalent to @@xx@@. $def->addElement('algebra', 'Inline', 'Inline', array()); // Algebra syntax, equivalent to @@xx@@.
$def->addElement('lang', 'Block', 'Flow', array(), array('lang'=>'CDATA')); // Original multilang style - only our hacked lang attribute. $def->addElement('lang', 'Block', 'Flow', array(), array('lang'=>'CDATA')); // Original multilang style - only our hacked lang attribute.
$def->addAttribute('span', 'xxxlang', 'CDATA'); // Current very problematic multilang. $def->addAttribute('span', 'xxxlang', 'CDATA'); // Current very problematic multilang.
// Use the built-in Ruby module to add annotation support.
$def->manager->addModule(new HTMLPurifier_HTMLModule_Ruby());
} }
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);