diff --git a/library/HTMLPurifier/Injector/AutoParagraph.php b/library/HTMLPurifier/Injector/AutoParagraph.php
index 8a60d59e..54585c48 100644
--- a/library/HTMLPurifier/Injector/AutoParagraph.php
+++ b/library/HTMLPurifier/Injector/AutoParagraph.php
@@ -5,6 +5,7 @@ require_once 'HTMLPurifier/Injector.php';
/**
* Injector that auto paragraphs text in the root node based on
* double-spacing.
+ * @todo Don't assume that root node means paragraphing is alright
*/
class HTMLPurifier_Injector_AutoParagraph extends HTMLPurifier_Injector
{
diff --git a/library/HTMLPurifier/Strategy/MakeWellFormed.php b/library/HTMLPurifier/Strategy/MakeWellFormed.php
index 2529f9b7..73bfe08a 100644
--- a/library/HTMLPurifier/Strategy/MakeWellFormed.php
+++ b/library/HTMLPurifier/Strategy/MakeWellFormed.php
@@ -40,11 +40,12 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
$escape_invalid_tags = $config->get('Core', 'EscapeInvalidTags');
$auto_paragraph = $config->get('Core', 'AutoParagraph');
- $auto_paragraph_skip = 0;
- $auto_paragraph_disabled = false;
- $context->register('AutoParagraphSkip', $auto_paragraph_skip);
+ $injector = array();
+ $injector['AutoParagraph'] = new HTMLPurifier_Injector_AutoParagraph();
+ $injector_skip['AutoParagraph'] = 0;
+ $injector_disabled['AutoParagraph'] = false;
- $injector = new HTMLPurifier_Injector_AutoParagraph();
+ $context->register('InjectorSkip', $injector_skip);
for ($tokens_index = 0; isset($tokens[$tokens_index]); $tokens_index++) {
@@ -52,19 +53,19 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
$token = $tokens[$tokens_index];
// this will be more complicated
- if ($auto_paragraph_skip > 0) {
- $auto_paragraph_skip--;
- $auto_paragraph_disabled = true;
+ if ($injector_skip['AutoParagraph'] > 0) {
+ $injector_skip['AutoParagraph']--;
+ $injector_disabled['AutoParagraph'] = true;
} else {
- $auto_paragraph_disabled = false;
+ $injector_disabled['AutoParagraph'] = false;
}
// quick-check: if it's not a tag, no need to process
if (empty( $token->is_tag )) {
if ($token->type === 'text') {
- if ($auto_paragraph && !$auto_paragraph_disabled) {
- $injector->handleText($token, $config, $context);
+ if ($auto_paragraph && !$injector_disabled['AutoParagraph']) {
+ $injector['AutoParagraph']->handleText($token, $config, $context);
}
}
@@ -116,8 +117,8 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
$current_nesting[] = $parent; // undo the pop
}
- if ($auto_paragraph && !$auto_paragraph_disabled) {
- $injector->handleStart($token, $config, $context);
+ if ($auto_paragraph && !$injector_disabled['AutoParagraph']) {
+ $injector['AutoParagraph']->handleStart($token, $config, $context);
}
$this->processToken($token, $config, $context);
@@ -213,8 +214,8 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
// this will be a bit more complicated when we add more formatters
// we need to prevent the same formatter from running twice on it
- $auto_paragraph_skip =& $context->get('AutoParagraphSkip');
- $auto_paragraph_skip = count($token);
+ $injector_skip =& $context->get('InjectorSkip');
+ $injector_skip['AutoParagraph'] = count($token);
} elseif ($token) {
// regular case