Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix invalid XML with spaces before the XML declaration #115

Conversation

naitoh
Copy link
Contributor

@naitoh naitoh commented Feb 19, 2024

Why?

XML declaration allowed only at the start of the document.

https://www.w3.org/TR/2006/REC-xml11-20060816/#document

[1]   document   ::=   ( prolog element Misc* ) - ( Char* RestrictedChar Char* ) 

It doesn't have S* before prolog.

https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-prolog

[22]   prolog   ::=   	XMLDecl Misc* (doctypedecl Misc*)?

It doesn't have S* before XMLdecl.

https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-XMLDecl

[23]   XMLDecl  ::=   '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'

It doesn't have S* before '<?xml'.

@kou kou changed the title Fixed invalid XML with spaces before the XML declaration in the test code test: Fix invalid XML with spaces before the XML declaration Feb 19, 2024
@kou
Copy link
Member

kou commented Feb 19, 2024

Good catch! But the important part in the specification is difference. The part you cited explains about an element (e.g. <root/>) not spaces. We should refer the followings:

https://www.w3.org/TR/2006/REC-xml11-20060816/#document

[1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )

It doesn't have S* before prolog.

https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-prolog

[22] prolog ::= XMLDecl Misc* (doctypedecl Misc*)?

It doesn't have S* before XMLdecl.

https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-XMLDecl

[23] XMLDecl ::= ''

It doesn't have S* before '<?xml'.

Could you update the PR description?

[Why]
XML declaration allowed only at the start of the document.

https://www.w3.org/TR/2006/REC-xml11-20060816/#document

```
[1]   document   ::=   ( prolog element Misc* ) - ( Char* RestrictedChar Char* )
```

It doesn't have `S*` before `prolog`.

https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-prolog

```
[22]   prolog   ::=   	XMLDecl Misc* (doctypedecl Misc*)?
```

It doesn't have `S*` before `XMLdecl`.

https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-XMLDecl

```
[23]   XMLDecl  ::=   '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
```

It doesn't have `S*` before `'<?xml'`.
@naitoh naitoh force-pushed the fixed_invalid_xml_with_spaces_before_the_xml_declaration_in_the_test_code branch from 49a6fa4 to 50a91a6 Compare February 20, 2024 11:31
@naitoh
Copy link
Contributor Author

naitoh commented Feb 20, 2024

@kou
Thank you for your comment.
I have updated this PR description.

@kou kou merged commit fb7ba27 into ruby:master Feb 20, 2024
39 checks passed
@kou
Copy link
Member

kou commented Feb 20, 2024

Thanks!

@naitoh naitoh deleted the fixed_invalid_xml_with_spaces_before_the_xml_declaration_in_the_test_code branch February 20, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants