summaryrefslogtreecommitdiff
path: root/src/HTML5/Parser
diff options
context:
space:
mode:
authorAsmir Mustafic <[email protected]>2017-09-01 17:07:16 +0200
committerGitHub <[email protected]>2017-09-01 17:07:16 +0200
commit39e2a7a30757948389a7ca744653a9adcca06bcb (patch)
tree5d6247ec963b0664b2728d5a319b8026f692a798 /src/HTML5/Parser
parentb8afbae8cdb626c786a1590b3a83d366933d807d (diff)
parent2a38f56f3772f943be436c7b411c2ae5fac6cee6 (diff)
Merge pull request #134 from Masterminds/ampersand-in-urls
Raw & in attributes
Diffstat (limited to 'src/HTML5/Parser')
-rw-r--r--src/HTML5/Parser/Tokenizer.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php
index 95dbf84..c42bc3d 100644
--- a/src/HTML5/Parser/Tokenizer.php
+++ b/src/HTML5/Parser/Tokenizer.php
@@ -1074,8 +1074,10 @@ class Tokenizer
}
$entity = CharacterReference::lookupDecimal($numeric);
}
- } // String entity.
- else {
+ } elseif ($tok === '=' && $inAttribute) {
+ return '&';
+ } else { // String entity.
+
// Attempt to consume a string up to a ';'.
// [a-zA-Z0-9]+;
$cname = $this->scanner->getAsciiAlphaNum();
@@ -1085,7 +1087,9 @@ class Tokenizer
// and continue on as the & is not part of an entity. The & will
// be converted to &amp; elsewhere.
if ($entity == null) {
- $this->parseError("No match in entity table for '%s'", $cname);
+ if (!$inAttribute || strlen($cname) === 0) {
+ $this->parseError("No match in entity table for '%s'", $cname);
+ }
$this->scanner->unconsume($this->scanner->position() - $start);
return '&';
}