Thread overview
[Issue 21227] import(".\\file") doesn't work on Windows
Sep 06, 2020
Andrey Zherikov
Sep 06, 2020
Andrey Zherikov
Sep 10, 2020
Dlang Bot
Sep 16, 2020
Dlang Bot
Sep 22, 2020
Dlang Bot
September 05, 2020
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, 2020
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, 2020
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, 2020
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

--
September 16, 2020
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

--
September 22, 2020
https://issues.dlang.org/show_bug.cgi?id=21227

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11748 "E2E tests for issue 21227: import(".\file") doesn't work on Windows" was merged into master:

- 5bee37fa5cf05a97b3d7ac0fdeb968fbb4db89b6 by Andrey Zherikov:
  E2E tests for issue 21227: import(".\file") doesn't work on Windows

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

--