diff --git a/CHANGES.md b/CHANGES.md index 51e6ffe8..e1e50262 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -34,6 +34,9 @@ next - Restore promoted files when they are deleted or changed in the source tree (#760, fix #759, @diml) +- Fix a crash when using an invalid alias name (#762, fixes #761, + @diml) + 1.0+beta20 (10/04/2018) ----------------------- diff --git a/src/jbuild.ml b/src/jbuild.ml index 49ba8564..55202713 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -1159,9 +1159,16 @@ module Alias_conf = struct ; package : Package.t option } + let alias_name sexp = + let s = string sexp in + if Filename.basename s <> s then + of_sexp_errorf sexp "%S is not a valid alias name" s + else + s + let v1 pkgs = record - (field "name" string >>= fun name -> + (field "name" alias_name >>= fun name -> field "deps" (list Dep_conf.t) ~default:[] >>= fun deps -> field_o "package" (Scope_info.package pkgs) >>= fun package -> field_o "action" (located Action.Unexpanded.t) >>= fun action -> diff --git a/test/blackbox-tests/test-cases/github761/run.t b/test/blackbox-tests/test-cases/github761/run.t index 1f74f841..3091e162 100644 --- a/test/blackbox-tests/test-cases/github761/run.t +++ b/test/blackbox-tests/test-cases/github761/run.t @@ -1,23 +1,4 @@ $ jbuilder build @bar - Internal error, please report upstream including the contents of _build/log. - Description: - ("Alias0.make: Invalid alias" (name foo/bar) (dir _build/default)) - Backtrace: - Raised at file "src/stdune/exn.ml", line 32, characters 5-10 - Called from file "src/build_system.ml", line 228, characters 8-146 - Called from file "src/gen_rules.ml", line 914, characters 16-49 - Called from file "src/gen_rules.ml", line 964, characters 8-37 - Called from file "src/stdune/list.ml", line 13, characters 10-13 - Called from file "src/gen_rules.ml", line 955, characters 4-777 - Called from file "src/gen_rules.ml", line 994, characters 19-30 - Called from file "src/build_system.ml", line 889, characters 6-62 - Called from file "src/build_system.ml", line 865, characters 6-59 - Re-raised at file "src/build_system.ml", line 876, characters 6-17 - Called from file "src/build_system.ml" (inlined), line 833, characters 32-63 - Called from file "src/build_system.ml", line 843, characters 4-24 - Called from file "src/build_interpret.ml", line 101, characters 24-40 - Called from file "src/build_interpret.ml", line 60, characters 31-43 - Called from file "src/build_interpret.ml", line 60, characters 31-43 - Called from file "src/build_system.ml", line 1215, characters 10-108 - Called from file "src/fiber/fiber.ml", line 359, characters 6-13 + File "dune", line 2, characters 8-15: + Error: "foo/bar" is not a valid alias name [1]