| @@ 46-50 (lines=5) @@ | ||
| 43 | ||
| 44 | if ($child->getName() == 'title') { |
|
| 45 | $titleCount++; |
|
| 46 | if ($titleCount > 1 && |
|
| 47 | $this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
| 48 | $logger->debug('Removing ' . $child . '. Only one "title" element allowed.'); |
|
| 49 | $this->removeChild($child); |
|
| 50 | } |
|
| 51 | } elseif ($child->getName() == 'base') { |
|
| 52 | $baseCount++; |
|
| 53 | if ($baseCount > 1 && |
|
| @@ 53-57 (lines=5) @@ | ||
| 50 | } |
|
| 51 | } elseif ($child->getName() == 'base') { |
|
| 52 | $baseCount++; |
|
| 53 | if ($baseCount > 1 && |
|
| 54 | $this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
| 55 | $logger->debug('Removing ' . $child . '. Maximum one "base" element allowed.'); |
|
| 56 | $this->removeChild($child); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||
| @@ 46-53 (lines=8) @@ | ||
| 43 | } |
|
| 44 | ||
| 45 | // Invalid token. |
|
| 46 | if ($child->getType() != Token::ELEMENT) { |
|
| 47 | if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
| 48 | $logger->debug('Removing ' . $child . '. "html" element only allows "head" and "body" elements children.'); |
|
| 49 | $this->removeChild($child); |
|
| 50 | } |
|
| 51 | ||
| 52 | continue; |
|
| 53 | } |
|
| 54 | ||
| 55 | // Check for HEAD and BODY |
|
| 56 | if ($child->getName() == 'head') { |
|
| @@ 63-69 (lines=7) @@ | ||
| 60 | } |
|
| 61 | ||
| 62 | // Remove extraneous HEAD elements. |
|
| 63 | if ($headCount > 1 && |
|
| 64 | $this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
| 65 | $logger->debug('Removing ' . $child . '. Only one "head" element allowed.'); |
|
| 66 | $this->removeChild($child); |
|
| 67 | ||
| 68 | continue; |
|
| 69 | } |
|
| 70 | } elseif ($child->getName() == 'body') { |
|
| 71 | $bodyCount++; |
|
| 72 | ||
| @@ 74-80 (lines=7) @@ | ||
| 71 | $bodyCount++; |
|
| 72 | ||
| 73 | // Remove extraneous BODY elements. |
|
| 74 | if ($bodyCount > 1 && |
|
| 75 | $this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
| 76 | $logger->debug('Removing ' . $child . '. Only one BODY element allowed.'); |
|
| 77 | $this->removeChild($child); |
|
| 78 | ||
| 79 | continue; |
|
| 80 | } |
|
| 81 | } elseif ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
| 82 | $logger->debug('Removing ' . $child . '. Only "head" or "body" elements are allowed as "html" element children.'); |
|
| 83 | $this->removeChild($child); |
|
| @@ 24-28 (lines=5) @@ | ||
| 21 | continue; |
|
| 22 | } |
|
| 23 | ||
| 24 | if ($child->getType() != Token::TEXT && |
|
| 25 | $this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
| 26 | $logger->debug('Removing ' . $child . '. Only text allowed inside TITLE.'); |
|
| 27 | $this->removeChild($child); |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| 31 | return true; |
|