Skip to content

Commit

Permalink
MDL-66104 output: HTMLPurifier to allow <nolink> tags everywhere
Browse files Browse the repository at this point in the history
Before the patch, HTMLPurifier was instructed to handle <nolink>
tags in block mode. That implies that any block tag enclosing it
had to be closed for HTML compliance.

But <noscript> tags are not part of the final output (they are
removed) but just internally used to skip filtering certain areas.

So they can be virtually everywhere, HTMLPurifier just should allow
them without any change, both to parent or children tags.
  • Loading branch information
stronk7 committed Aug 1, 2019
1 parent 0e4e2ce commit a588974
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/tests/htmlpurifier_test.php
Expand Up @@ -64,6 +64,11 @@ public function test_nolink() {
$text = '<nolink>xxx<em>xx</em><div>xxx</div></nolink>';
$result = purify_html($text, array());
$this->assertSame($text, $result);

// Ensure nolink doesn't force open tags to be closed, so can be virtually everywhere.
$text = '<p><nolink><div>no filters</div></nolink></p>';
$result = purify_html($text, array());
$this->assertSame($text, $result);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/weblib.php
Expand Up @@ -1856,7 +1856,7 @@ function purify_html($text, $options = array()) {
}

if ($def = $config->maybeGetRawHTMLDefinition()) {
$def->addElement('nolink', 'Block', 'Flow', array()); // Skip our filters inside.
$def->addElement('nolink', 'Inline', 'Flow', array()); // Skip our filters inside.
$def->addElement('tex', 'Inline', 'Inline', array()); // Tex 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.
Expand Down

0 comments on commit a588974

Please sign in to comment.