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

Improve error for unexpected closing xml tag #12021

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

tobil4sk
Copy link
Member

#12015 (comment)

On a side note, the error seems odd too, I don't know if a plain </xml> should complain about being unterminated...

@kLabz
Copy link
Contributor

kLabz commented Feb 19, 2025

Will have to check with @ncannasse about that, iirc he wanted inline xml to have very few limitations on terms of syntax

@tobil4sk
Copy link
Member Author

Note: the reason the lexer continues past </ is because empty tags are allowed: 68fdc5a. Otherwise it would give invalid character.

@Simn
Copy link
Member

Simn commented Feb 19, 2025

Will have to check with @ncannasse about that, iirc he wanted inline xml to have very few limitations on terms of syntax

The point here is that this isn't really an xml-literal in the first place. It's not like you can close it with <//xml> so there's nothing you can do with this syntax, unless I'm missing something.

@tobil4sk
Copy link
Member Author

It's not like you can close it with <//xml> so there's nothing you can do with this syntax, unless I'm missing something.

You can close it with </> though, since it's parsed as an empty tag 😅

@Simn
Copy link
Member

Simn commented Feb 19, 2025

I thought an empty tag was <>, why is </ parsed like that?

@tobil4sk
Copy link
Member Author

For example with: </</>

The tag name is the empty string between the first < and /, the / is the middle content and the </> is the closing tag.

It's just a side effect of how empty tags are handled for not_xml, it doesn't really make sense.

@Simn
Copy link
Member

Simn commented Feb 20, 2025

Something is definitely wrong here, there's even a comment in lexer.ml that says (* don't allow self-closing fragments *).

@tobil4sk
Copy link
Member Author

tobil4sk commented Feb 20, 2025

Something is definitely wrong here, there's even a comment in lexer.ml that says (* don't allow self-closing fragments *).

In general this is consistent with how xml literals behave.

<tag...</tag> is allowed, and </</> is just an edge case of that with an empty tag name. It's the same as < </> or <.</> just with a slash in the middle, which happens to produce </ at the beginning.

This patch just disallows an empty tag name if it is immediately followed by /, in order to catch the case of a rogue closing tag, but the cost is breaking </...</>, so it's a question of whether that is an acceptable constraint or not.

@skial skial mentioned this pull request Feb 20, 2025
1 task
@Simn
Copy link
Member

Simn commented Feb 20, 2025

Right, I had forgotten how silly all this is...

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.

3 participants