Thread overview
[Issue 21227] import(".\\file") doesn't work on Windows
Sep 10
Dlang Bot
6 days ago
Dlang Bot
September 05
https://issues.dlang.org/show_bug.cgi?id=21227

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg

--- Comment #1 from moonlightsentinel@disroot.org ---
Plainly allowing is not the right fix (given the contract of the function) because it allows to write absolute paths:

Try e.g.:

pragma(msg, import(`\papth\to\dmd\README.md`));

--
September 06
https://issues.dlang.org/show_bug.cgi?id=21227

--- Comment #2 from Andrey Zherikov <andrey.zherikov@gmail.com> ---
(In reply to moonlightsentinel from comment #1)
> Plainly allowing is not the right fix (given the contract of the function) because it allows to write absolute paths:
> 
> Try e.g.:
> 
> pragma(msg, import(`\papth\to\dmd\README.md`));

Whether to allow absolute path or not is a separate question and I agree with denying them. The issue here is in rejecting the valid path character.

Another issue here is that error message is useless because it doesn't shed any light why file ".\file" can't be found although it exists for sure.

--
September 06
https://issues.dlang.org/show_bug.cgi?id=21227

--- Comment #3 from Andrey Zherikov <andrey.zherikov@gmail.com> ---
I'm not an expert in this subject but IMO the restrictions should simple:
 - Do not allow absolute path. There is FileName.absolute function that can be
used: https://github.com/dlang/dmd/blob/master/src/dmd/root/filename.d#L103
 - Do not allow reference to parent (i.e. ".." ) directory anywhere in the path

--
September 10
https://issues.dlang.org/show_bug.cgi?id=21227

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@andrey-zherikov created dlang/dmd pull request #11720 "Fix path validation in import expression (issue #21227)" mentioning this issue:

- Fix path validation in import expression (issue #21227)

https://github.com/dlang/dmd/pull/11720

--
6 days ago
https://issues.dlang.org/show_bug.cgi?id=21227

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11720 "Fix path validation in import expression (issue #21227)" was merged into master:

- b6ac2891b28d4f25136b5c2bf5100f4837748af6 by Andrey Zherikov:
  Fix issue 21227: import(".\file") doesn't work on Windows

https://github.com/dlang/dmd/pull/11720

--