actonlang / acton

The Acton Programming Language
https://www.acton-lang.org/
BSD 3-Clause "New" or "Revised" License
80 stars 7 forks source link

Check deps name are safe #1909

Closed plajjan closed 2 months ago

plajjan commented 2 months ago

When we pass the name of dependencies to Zig through build.zig and build.zig.zon, not all names are safe. Like the dependency name is literally used in build.zig, so Zig source code. I'm not sure exactly what is allowed there but at the least - doesn't work since it is the minus operator and cannot be part of a name.

I opted to just allowed plain ascii names, that must start with a letter and then followed by letters, numbers and underscore.

The user now gets an error if a disallowed name is used, via acton pkg add, acton zig-pkg add/remove as well as if it is read from build.act.json (in which case it needs to be manually edited).

I briefly considered rewriting names, but it leads to other problems, and so I ultimately decided to just error out instead.

Fixes #1886