Skip to content

Commit

Permalink
Make sure we don't load internal files
Browse files Browse the repository at this point in the history
  • Loading branch information
ogoffart committed Jun 16, 2023
1 parent bbfbff9 commit 300cb06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions internal/compiler/tests/syntax/imports/import_builtin.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.0 OR LicenseRef-Slint-commercial

// Even if that file exist in the style, it shouldn't be loaded
import { StyleMetrics } from "std-widgets-impl.slint";
// ^error{Cannot find requested import "std-widgets-impl.slint" in the include search path}
6 changes: 5 additions & 1 deletion internal/compiler/typeloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,11 @@ impl TypeLoader {
}
}
}))
.chain(std::iter::once_with(|| format!("builtin:/{}", self.style).into()))
.chain(
(file_to_import == "std-widgets.slint"
|| referencing_file.map_or(false, |x| x.starts_with("builtin:/")))
.then(|| format!("builtin:/{}", self.style).into()),
)
.find_map(|include_dir| {
let candidate = include_dir.join(file_to_import);
crate::fileaccess::load_file(&candidate).map(|virtual_file| {
Expand Down

0 comments on commit 300cb06

Please sign in to comment.