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

BOM breaks parseXmlDeclaration #104

Open
ppebb opened this issue Nov 28, 2024 · 0 comments
Open

BOM breaks parseXmlDeclaration #104

ppebb opened this issue Nov 28, 2024 · 0 comments

Comments

@ppebb
Copy link

ppebb commented Nov 28, 2024

In files containing a BOM (utf <feff>) at the beginning of the file, parseXmlDeclaration in XmlParser.lua will error thinking that the XML declaration is not at the beginning of the string.

local xml2lua = require("xml2lua")
local handler = require("xmlhandler.tree")
local h = handler:new()
local parser = xml2lua.parser(h)

parser:parse("<?xml version=\"1.0\" encoding=\"utf-8\"?>")

Running this snippet (ensure you copy and paste, as there is an invisible BOM right before the <) will produce the following output:

./xml2lua.lua:92: XMLDecl not at start of document [char=1]

stack traceback:
	[C]: in function 'error'
	./xml2lua.lua:92: in field 'errorHandler'
	./XmlParser.lua:133: in upvalue 'err'
	./XmlParser.lua:194: in upvalue 'parseXmlDeclaration'
	./XmlParser.lua:347: in upvalue 'parseTagType'
	./XmlParser.lua:429: in function 'XmlParser.parse'
	stdin:6: in main chunk
	[C]: in ?```
ppebb added a commit to ppebb/solution-nvim that referenced this issue Nov 28, 2024
Two functions are now available, add_nuget_dep and add_local_dep. This
commit also includes the removal of BOM characters from the beginning of
projects to avoid breaking xml2lua (see
manoelcampos/xml2lua#104).

Associated removal functions will be added later. add_project_dep will
also be added later.
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

No branches or pull requests

1 participant