Skip to content

Commit d018b0c

Browse files
committed
Don't allow invalid identifiers in the wizard or JLL packages
1 parent db769d4 commit d018b0c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/AutoBuild.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ function register_jll(name, build_version, dependencies;
380380
code_dir=joinpath(Pkg.devdir(), "$(name)_jll"),
381381
gh_auth=github_auth(;allow_anonymous=false),
382382
gh_username=gh_get_json(DEFAULT_API, "/user"; auth=gh_auth)["login"])
383+
if !Base.isidentifier(name)
384+
error("Package name \"$(name)\" is not a valid identifier")
385+
end
383386
# Calculate tree hash of wrapper code
384387
wrapper_tree_hash = bytes2hex(Pkg.GitTools.tree_hash(code_dir))
385388

@@ -912,6 +915,9 @@ end
912915
function build_jll_package(src_name::String, build_version::VersionNumber, code_dir::String,
913916
build_output_meta::Dict, dependencies::Vector, bin_path::String;
914917
verbose::Bool = false, lazy_artifacts::Bool = false)
918+
if !Base.isidentifier(src_name)
919+
error("Package name \"$(src_name)\" is not a valid identifier")
920+
end
915921
# Make way, for prince artifacti
916922
mkpath(joinpath(code_dir, "src", "wrappers"))
917923

src/wizard/obtain_source.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ function get_name_and_version(state::WizardState)
328328
msg = "Enter a name for this project. This will be used for filenames:"
329329
new_name = nonempty_line_prompt("Name", msg; ins=state.ins, outs=state.outs)
330330

331+
if !Base.isidentifier(new_name)
332+
println(state.outs, "\"$(new_name)\" is an invalid identifier. Try again.")
333+
continue
334+
end
335+
331336
# Check to see if this project name already exists
332337
if case_insensitive_file_exists(joinpath(yggdrasil_path, yggdrasil_build_tarballs_path(new_name)))
333338
println(state.outs, "A build recipe with that name already exists within Yggdrasil.")

0 commit comments

Comments
 (0)