Skip to content

Commit

Permalink
Require spaces between attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed May 22, 2023
1 parent 1eefdc9 commit 3562bff
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/reader/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ pub enum OpeningTagSubstate {
AfterAttributeName,

InsideAttributeValue,
AfterAttributeValue,
}

#[derive(Copy, Clone, PartialEq)]
Expand Down
15 changes: 11 additions & 4 deletions src/reader/parser/inside_opening_tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl PullParser {
Some(this.error(SyntaxError::CannotUndefinePrefix(ln.into())))
} else {
this.nst.put(name.local_name.clone(), value);
this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideTag))
this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::AfterAttributeValue))
}
}

Expand All @@ -86,7 +86,7 @@ impl PullParser {
Some(this.error(SyntaxError::InvalidDefaultNamespace(value.into()))),
_ => {
this.nst.put(namespace::NS_NO_PREFIX, value.clone());
this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideTag))
this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::AfterAttributeValue))
}
},

Expand All @@ -96,11 +96,18 @@ impl PullParser {
name: name.clone(),
value
});
this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideTag))
this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::AfterAttributeValue))
}
}
}
})
}),

OpeningTagSubstate::AfterAttributeValue => match t {
Token::Character(c) if is_whitespace_char(c) => self.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::InsideTag)),
Token::TagEnd => self.emit_start_element(false),
Token::EmptyTagEnd => self.emit_start_element(true),
_ => Some(self.error(SyntaxError::UnexpectedTokenInOpeningTag(t)))
},
}
}
}
2 changes: 0 additions & 2 deletions tests/oasis.fail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ o-p12fail6 p12fail6.xml built-in entity refs excluded
o-p12fail7 p12fail7.xml The public ID has a tab character, which is disallowed
o-p30fail1 p30fail1.xml An XML declaration is not the same as a TextDecl
o-p31fail1 p31fail1.xml external subset excludes doctypedecl
o-p40fail1 p40fail1.xml S is required between attributes
o-p44fail4 p44fail4.xml Whitespace required between attributes.
o-p45fail2 p45fail2.xml S before contentspec is required.
o-p45fail3 p45fail3.xml only one content spec
o-p45fail4 p45fail4.xml no comments in declarations (contrast with SGML)
Expand Down
2 changes: 0 additions & 2 deletions tests/sun-not-wf.fail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ attlist06 attlist06.xml SGML's NAME attribute type is not allowed.
attlist07 attlist07.xml SGML's NAMES attribute type is not allowed.
attlist08 attlist08.xml SGML's #CURRENT is not allowed.
attlist09 attlist09.xml SGML's #CONREF is not allowed.
attlist10 attlist10.xml Whitespace required between attributes
attlist11 attlist11.xml Whitespace required between attributes
cond01 cond01.xml Only INCLUDE and IGNORE are conditional section keywords
cond02 cond02.xml Must have keyword in conditional sections
content01 content01.xml No whitespace before "?" in content model
Expand Down
1 change: 0 additions & 1 deletion tests/xmltest.fail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ not-wf-sa-181 181.xml Internal parsed entities must match the content product
not-wf-sa-182 182.xml Internal parsed entities must match the content production to be well formed.
not-wf-sa-183 183.xml Mixed content declarations may not include content particles.
not-wf-sa-184 184.xml In mixed content models, element names must not be parenthesized.
not-wf-sa-186 186.xml Whitespace is required between attribute/value pairs.
not-wf-not-sa-001 001.xml Conditional sections must be properly terminated ("]>" used instead of "]]>").
not-wf-not-sa-002 002.xml Processing instruction target names may not be "XML" in any combination of cases.
not-wf-not-sa-003 003.xml Conditional sections must be properly terminated ("]]>" omitted).
Expand Down

0 comments on commit 3562bff

Please sign in to comment.