Conversation

naitoh

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'.

@koukou 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

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'`.
@naitohnaitoh 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

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

@koukou merged commit fb7ba27 into ruby:master Feb 20, 2024
@kou

Thanks!

@naitohnaitoh 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 . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.