Skip to content

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

Merged
kou merged 1 commit intoruby:masterfrom
naitoh:fixed_invalid_xml_with_spaces_before_the_xml_declaration_in_the_test_code
Feb 20, 2024
Merged

test: Fix invalid XML with spaces before the XML declaration#115
kou merged 1 commit intoruby:masterfrom
naitoh:fixed_invalid_xml_with_spaces_before_the_xml_declaration_in_the_test_code

Conversation

@naitoh
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@kou
Copy link
Copy Markdown
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants