Skip to content

Fix phx.new crash when parent directory contains a colon#6633

Open
eagle-head wants to merge 1 commit intophoenixframework:mainfrom
eagle-head:fix/colon-in-path-phx-new
Open

Fix phx.new crash when parent directory contains a colon#6633
eagle-head wants to merge 1 commit intophoenixframework:mainfrom
eagle-head:fix/colon-in-path-phx-new

Conversation

@eagle-head
Copy link
Contributor

mix phx.new crashes with a KeyError when the parent directory
contains a colon (e.g., /mnt/usb-Seagate:0/code/myapp).

The regex in Project.expand_path_with_bindings/2 matches
:[a-zA-Z0-9_]+ against the full absolute path, so a directory
like 0:0 causes :0 to be interpreted as a template binding.

The fix applies the binding expansion only to the relative template
path before joining it with the base path.

To reproduce (before fix)

mkdir 0:0 && cd 0:0
mix phx.new myapp
# => ** (KeyError) key :"0" not found in: %Phx.New.Project{...}

After fix

mkdir 0:0 && cd 0:0
mix phx.new myapp
# => works correctly

Closes #6585

The `:binding` expansion regex in `Project.expand_path_with_bindings/2`
was applied to the full absolute path, causing colons in parent
directories (e.g., `/mnt/usb-Seagate:0/code`) to be incorrectly
interpreted as template bindings.

Now the binding expansion is applied only to the relative template
path before joining with the base path.

Closes phoenixframework#6585
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Having a colon in the path breaks phx.new.

1 participant