diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php
index 513ee7b43ba..460d7e45980 100644
--- a/lib/tests/weblib_test.php
+++ b/lib/tests/weblib_test.php
@@ -567,4 +567,19 @@ EXPECTED;
$this->assertSame($expected, strip_pluginfile_content($source));
}
+ public function test_purify_html_ruby() {
+
+ $this->resetAfterTest();
+
+ $ruby =
+ "
京都は" .
+ "日本の" .
+ "都です。
";
+ $illegal = '';
+
+ $cleaned = purify_html($ruby . $illegal);
+ $this->assertEquals($ruby, $cleaned);
+
+ }
+
}
diff --git a/lib/weblib.php b/lib/weblib.php
index bd3689b3313..bb671da80c0 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -1705,7 +1705,7 @@ function purify_html($text, $options = array()) {
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.DefinitionID', 'moodlehtml');
- $config->set('HTML.DefinitionRev', 2);
+ $config->set('HTML.DefinitionRev', 3);
$config->set('Cache.SerializerPath', $cachedir);
$config->set('Cache.SerializerPermissions', $CFG->directorypermissions);
$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('lang', 'Block', 'Flow', array(), array('lang'=>'CDATA')); // Original multilang style - only our hacked lang attribute.
$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);