aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-09-26 13:10:18 +0100
committergingerBill <bill@gingerbill.org>2023-09-26 13:10:18 +0100
commitfb935541c9f8c7bb3f92747a22737a49625d102a (patch)
tree044f36a1e0e25d4cb666103d124d46f71d2f0600 /src/parser.cpp
parent47023b2e6c8516800e17579c651798eec2b013e4 (diff)
Fix #2809 - disallow files to start with `_`
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 94e91fbb2..a4bf949b9 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -5988,6 +5988,16 @@ gb_internal ParseFileError process_imported_file(Parser *p, ImportedFile importe
}
}
+ {
+ String name = file->fullpath;
+ name = remove_directory_from_path(name);
+ name = remove_extension_from_path(name);
+
+ if (string_starts_with(name, str_lit("_"))) {
+ syntax_error(pos, "Files cannot start with '_', got '%.*s'", LIT(file->fullpath));
+ }
+ }
+
if (build_context.command_kind == Command_test) {
String name = file->fullpath;
name = remove_extension_from_path(name);
@@ -5998,6 +6008,7 @@ gb_internal ParseFileError process_imported_file(Parser *p, ImportedFile importe
}
}
+
if (parse_file(p, file)) {
MUTEX_GUARD_BLOCK(&pkg->files_mutex) {
array_add(&pkg->files, file);