Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape glob patterns #7709

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions crates/uv-workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,12 @@ impl Workspace {

// Add all other workspace members.
for member_glob in workspace_definition.clone().members.unwrap_or_default() {
let absolute_glob = workspace_root
.simplified()
.join(member_glob.as_str())
.to_string_lossy()
.to_string();
let absolute_glob = PathBuf::from(glob::Pattern::escape(
workspace_root.simplified().to_string_lossy().as_ref(),
))
.join(member_glob.as_str())
.to_string_lossy()
.to_string();
for member_root in glob(&absolute_glob)
.map_err(|err| WorkspaceError::Pattern(absolute_glob.to_string(), err))?
{
Expand Down Expand Up @@ -1284,11 +1285,12 @@ fn is_excluded_from_workspace(
workspace: &ToolUvWorkspace,
) -> Result<bool, WorkspaceError> {
for exclude_glob in workspace.exclude.iter().flatten() {
let absolute_glob = workspace_root
.simplified()
.join(exclude_glob.as_str())
.to_string_lossy()
.to_string();
let absolute_glob = PathBuf::from(glob::Pattern::escape(
workspace_root.simplified().to_string_lossy().as_ref(),
))
.join(exclude_glob.as_str())
.to_string_lossy()
.to_string();
for excluded_root in glob(&absolute_glob)
.map_err(|err| WorkspaceError::Pattern(absolute_glob.to_string(), err))?
{
Expand All @@ -1309,11 +1311,12 @@ fn is_included_in_workspace(
workspace: &ToolUvWorkspace,
) -> Result<bool, WorkspaceError> {
for member_glob in workspace.members.iter().flatten() {
let absolute_glob = workspace_root
.simplified()
.join(member_glob.as_str())
.to_string_lossy()
.to_string();
let absolute_glob = PathBuf::from(glob::Pattern::escape(
workspace_root.simplified().to_string_lossy().as_ref(),
))
.join(member_glob.as_str())
.to_string_lossy()
.to_string();
for member_root in glob(&absolute_glob)
.map_err(|err| WorkspaceError::Pattern(absolute_glob.to_string(), err))?
{
Expand Down
Loading