forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
330 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
11 changes: 11 additions & 0 deletions
11
...htmlpurifier/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
AutoFormat.RemoveSpansWithoutAttributes | ||
TYPE: bool | ||
VERSION: 4.0.1 | ||
DEFAULT: false | ||
--DESCRIPTION-- | ||
<p> | ||
This directive causes <code>span</code> tags without any attributes | ||
to be removed. It will also remove spans that had all attributes | ||
removed during processing. | ||
</p> | ||
--# vim: et sw=4 sts=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
lib/htmlpurifier/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Output.FlashCompat | ||
TYPE: bool | ||
VERSION: 4.1.0 | ||
DEFAULT: false | ||
--DESCRIPTION-- | ||
<p> | ||
If true, HTML Purifier will generate Internet Explorer compatibility | ||
code for all object code. This is highly recommended if you enable | ||
%HTML.SafeObject. | ||
</p> | ||
--# vim: et sw=4 sts=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
lib/htmlpurifier/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/** | ||
* Injector that removes spans with no attributes | ||
*/ | ||
class HTMLPurifier_Injector_RemoveSpansWithoutAttributes extends HTMLPurifier_Injector | ||
{ | ||
public $name = 'RemoveSpansWithoutAttributes'; | ||
public $needed = array('span'); | ||
|
||
private $attrValidator; | ||
|
||
/** | ||
* Used by AttrValidator | ||
*/ | ||
private $config; | ||
private $context; | ||
|
||
public function prepare($config, $context) { | ||
$this->attrValidator = new HTMLPurifier_AttrValidator(); | ||
$this->config = $config; | ||
$this->context = $context; | ||
return parent::prepare($config, $context); | ||
} | ||
|
||
public function handleElement(&$token) { | ||
if ($token->name !== 'span' || !$token instanceof HTMLPurifier_Token_Start) { | ||
return; | ||
} | ||
|
||
// We need to validate the attributes now since this doesn't normally | ||
// happen until after MakeWellFormed. If all the attributes are removed | ||
// the span needs to be removed too. | ||
$this->attrValidator->validateToken($token, $this->config, $this->context); | ||
$token->armor['ValidateAttributes'] = true; | ||
|
||
if (!empty($token->attr)) { | ||
return; | ||
} | ||
|
||
$nesting = 0; | ||
$spanContentTokens = array(); | ||
while ($this->forwardUntilEndToken($i, $current, $nesting)) {} | ||
|
||
if ($current instanceof HTMLPurifier_Token_End && $current->name === 'span') { | ||
// Mark closing span tag for deletion | ||
$current->markForDeletion = true; | ||
// Delete open span tag | ||
$token = false; | ||
} | ||
} | ||
|
||
public function handleEnd(&$token) { | ||
if ($token->markForDeletion) { | ||
$token = false; | ||
} | ||
} | ||
} | ||
|
||
// vim: et sw=4 sts=4 |
Oops, something went wrong.