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

[CLOSED] Right-clicking and creating new files or folders doesn't resolve paths for .. and / #10071

Open
core-ai-bot opened this issue Aug 30, 2021 · 6 comments

Comments

@core-ai-bot
Copy link
Member

Issue by humphd
Thursday Aug 20, 2015 at 02:12 GMT
Originally opened as adobe/brackets#11609


It's possible to right-click in the file tree and create a file (or filder) named ../something or just .., and the path isn't resolved, but rather the .. and / characters are treated as literals to be used in the filename itself.

screenshot 82

First discovered by@Pomax in https://github.com/humphd/brackets/issues/434, and now I'm filing upstream, since this is really a bug in Brackets.

@core-ai-bot
Copy link
Member Author

Comment by tallandroid
Thursday Aug 20, 2015 at 10:27 GMT


Works for me on mac. I created both a file and a folder with prefix to be .. in a subfolder. Both got created in the parent folder. However , the UI shows this

image

Can you confirm if the directory structure is as expected in the file system. In that case , its a bug with the File Tree UI.

@core-ai-bot
Copy link
Member Author

Comment by petetnt
Thursday Aug 20, 2015 at 14:50 GMT


Nice find! I like how it sort of works how you would expect it to regarding creating files with relative paths and it also sort of works how you would expect it to work if they were just filenames.

Another case that brings really weird behavior is naving a file /foo.js. It's created as foo.js, but stays as /foo.js in the editor until refreshing.

I'd say the expected behavior would be showing a "filename cannot contain error", something similar to this Windows example:

image

@core-ai-bot
Copy link
Member Author

Comment by humphd
Thursday Aug 20, 2015 at 16:16 GMT


@petetnt, I had the same thought, to show a "filename cannot contain..." error of some kind. I don't think you want people using the filename as a way to bypass pathing.

@core-ai-bot
Copy link
Member Author

Comment by petetnt
Wednesday Oct 28, 2015 at 09:54 GMT


@peterflynn noted on the mailing list (Brackets-Dev) that error/validation is there already, but it's not in a tooltip form but a modal error that appears when there are invalid characters. The "/" case is just failing:

image

@core-ai-bot
Copy link
Member Author

Comment by tallandroid
Wednesday Oct 28, 2015 at 10:21 GMT


Submitted a pull request : adobe/brackets#11862

As@peterflynn pointed out , the validation is failing for this case.

The reason being, the validation checks for the basename of the file which strips out the /../ from the fullPath. So the validation code gets the basename which is perfectly valid.
Another weird thing I found was that / is being considered a valid character according to brackets for mac platforms, which in my opinion shouldn't be the case. Feel free to provide a counter point.

The pull request does change the inherent behavior of FileUtils.baseName though. It makes sense , cos if the fullpath contains the parent relative path , it should be returned along with the baseName. I preferred this over the option of creating a new function like FileUtils.getNormalizedPath and running the validation against that. Open to options.

@core-ai-bot
Copy link
Member Author

Comment by tallandroid
Sunday Aug 07, 2016 at 03:25 GMT


This can be closed now.

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

No branches or pull requests

1 participant