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

XMLTokenMaker does not follow XML spec (it wants ASCII element names) #542

Closed
predi opened this issue Apr 22, 2024 · 1 comment
Closed
Assignees
Labels
bug syntax-highlighting Syntax highlighting requests for new languaages or bug fixes
Milestone

Comments

@predi
Copy link

predi commented Apr 22, 2024

XMLTokenMaker.flex assumes ASCII element names, which is evident from its TagName production. This production is incorrect per XML spec, which allows far more characters to appear here.

For some reason, it does allow attribute names with a wider character range to be used in their names, evident from InTagIdentifier production.

This results in strange token sequences being produced for well formed XML, such as below.

<cszčšž:test xmlns:cszčšž="test:uri"/>

So, instead of a simple [delimiter ('<'), tag name ("cszčšž:test"), whitespace (" ")] sequence, we get [delimiter ('<'), tag name ("csz"), attribute name ("čšž:test"), whitespace (" ")] for the above element (up to that first namespace attribute).

Note: apparently GitHub's own lexer gets this wrong, but any compliant XML validator would lex the above example without issues.

XMLTokenMaker.flex should be revised to more closely resemble the XML spec:

[4]   	NameStartChar	   ::=   	":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[4a]   	NameChar	   ::=   	NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[5]   	Name	   ::=   	NameStartChar (NameChar)*

[40]   	STag	   ::=   	'<' Name (S Attribute)* S? '>'
[41]   	Attribute	   ::=   	Name Eq AttValue 

I'm seeing this with an older version of RSTA, but since the flex file has not been changed much in between, the latest versions are bound to exhibit the same.

@predi predi added the bug label Apr 22, 2024
@bobbylight bobbylight self-assigned this Jun 9, 2024
@bobbylight bobbylight added the syntax-highlighting Syntax highlighting requests for new languaages or bug fixes label Jun 9, 2024
@bobbylight
Copy link
Owner

Thanks for the bug report! This will be in the next release.

@bobbylight bobbylight added this to the 3.4.1 milestone Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug syntax-highlighting Syntax highlighting requests for new languaages or bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants