Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

added ' parsing for attributes #34

Merged
merged 1 commit into from

1 participant

@Pomax
Owner

also deleted an obsolete spec.html in the demo dir

@Pomax Pomax merged commit 27bf788 into mozilla:gh-pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 11, 2012
  1. @Pomax
This page is out of date. Refresh to see the latest.
Showing with 83 additions and 7 deletions.
  1. +0 −4 demo/spec.html
  2. +11 −3 slowparse.js
  3. +72 −0 spec/index.html
View
4 demo/spec.html
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<meta charset="utf-8">
-<title>Specification Moved!</title>
-<p>The specification has been moved <a href="../spec/">here</a>.</p>
View
14 slowparse.js
@@ -26,6 +26,7 @@ var Slowparse = (function() {
var CHARACTER_ENTITY_REFS = {
lt: "<",
gt: ">",
+ apos: "'",
quot: '"',
amp: "&"
};
@@ -1108,11 +1109,18 @@ var Slowparse = (function() {
// though the HTML5 standard allows them to sometimes go unquoted.
this.stream.eatSpace();
this.stream.makeToken();
- if (this.stream.next() != '"')
+ var quoteType = this.stream.next();
+ if (quoteType !== '"' && quoteType !== "'") {
throw new ParseError("UNQUOTED_ATTR_VALUE", this);
- this.stream.eatWhile(/[^"]/);
- if (this.stream.next() != '"')
+ }
+ if (quoteType === '"') {
+ this.stream.eatWhile(/[^"]/);
+ } else {
+ this.stream.eatWhile(/[^']/);
+ }
+ if (this.stream.next() !== quoteType) {
throw new ParseError("UNTERMINATED_ATTR_VALUE", this, nameTok);
+ }
var valueTok = this.stream.makeToken();
var unquotedValue = replaceEntityRefs(valueTok.value.slice(1, -1));
this.domBuilder.attribute(nameTok.value, unquotedValue, {
View
72 spec/index.html
@@ -281,6 +281,78 @@ <h1 class="error-category">HTML Errors</h1>
</div>
<div class="test">
<script type="text/x-bad-html">
+ hello <em class='foo>there</em>
+ </script>
+ <script type="application/json">
+ {
+ "type": "UNTERMINATED_ATTR_VALUE",
+ "openTag": {
+ "name": "em",
+ "start": 6
+ },
+ "attribute": {
+ "name": {
+ "value": "class",
+ "start": 10,
+ "end": 15
+ },
+ "value": {
+ "start": 16
+ }
+ }
+ }
+ </script>
+</div>
+<div class="test">
+ <script type="text/x-bad-html">
+ hello <em class="foo'>there</em>
+ </script>
+ <script type="application/json">
+ {
+ "type": "UNTERMINATED_ATTR_VALUE",
+ "openTag": {
+ "name": "em",
+ "start": 6
+ },
+ "attribute": {
+ "name": {
+ "value": "class",
+ "start": 10,
+ "end": 15
+ },
+ "value": {
+ "start": 16
+ }
+ }
+ }
+ </script>
+</div>
+<div class="test">
+ <script type="text/x-bad-html">
+ hello <em class='foo">there</em>
+ </script>
+ <script type="application/json">
+ {
+ "type": "UNTERMINATED_ATTR_VALUE",
+ "openTag": {
+ "name": "em",
+ "start": 6
+ },
+ "attribute": {
+ "name": {
+ "value": "class",
+ "start": 10,
+ "end": 15
+ },
+ "value": {
+ "start": 16
+ }
+ }
+ }
+ </script>
+</div>
+<div class="test">
+ <script type="text/x-bad-html">
hi<!--blah
</script>
<script type="application/json">
Something went wrong with that request. Please try again.