Ticket #2366 defect new

Opened 6 years ago

Last modified 22 months ago

FilePath should allow access to all possible paths on Windows

Reported by: jknight Owned by:
Priority: normal Milestone:
Component: core Keywords: unicode windows
Cc: teratorn, wilcoxjg@…, davidsarah, zooko@… Branch: /branches/win-filepath-2366-2
(diff, github, buildbot, log)
Author: Launchpad Bug:

Description (last modified by exarkun) (diff)

FilePath incorrectly prohibits access to certain files, due to the crummy APIs it's using.

For example, you can actually have a file called "CON" on windows, and it is accessible by quoting the path in various ways (or by accessing it via native Windows APIs), but FilePath would currently consider that path a security violation, regardless of whether it actually exists.

Additionally, Windows paths may natively be unicode. FilePath doesn't really pay attention to unicode vs str, so it may be broken with respect to non-ASCII(?) paths. Even if it does work, it needs unit tests to demonstrate this and prevent regressions.

Change History

1

  Changed 6 years ago by glyph

  • description modified (diff)

2

  Changed 6 years ago by glyph

This should also include using MOVE_FILE_REPLACE_EXISTING to actually make setContent (and moveTo, of course) atomic.

3

  Changed 6 years ago by teratorn

  • cc teratorn added

4

  Changed 5 years ago by glyph

  • description modified (diff)
  • summary changed from Make filepath work on windows to FilePath should allow access to all possible paths on Windows

5

  Changed 5 years ago by glyph

I have created #3454 for the separate issue of setContent and moveTo being non-atomic.

6

follow-ups: ↓ 7 ↓ 8   Changed 2 years ago by <automation>

  • owner jknight deleted

7

in reply to: ↑ 6   Changed 2 years ago by Zancas

Replying to <automation>:

Hi all I see that #4736 was closed as a duplicate of this ticket, but it's not clear to me that FilePath handles Unicode in all cases. Does it?

8

in reply to: ↑ 6   Changed 2 years ago by Zancas

  • cc wilcoxjg@… added

Replying to <automation>:

Hi all I see that #4736 was closed as a duplicate of this ticket, but it's not clear to me that FilePath handles Unicode in all cases. Does it?

9

  Changed 2 years ago by davidsarah

  • keywords unicode windows added
  • cc davidsarah added

The Tahoe-LAFS project  would like to use FilePath, but we're concerned that lack of Unicode support would cause a regression on Windows relative to our existing code that uses unicode strings for paths.

10

  Changed 2 years ago by davidsarah

By the way, I don't really agree that it is a good idea to create Windows files with names that are usually prohibited. The Microsoft article on this is pretty clear:

Do not use the following reserved device names for the name of a file:

CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. For more information, see Namespaces.

The fact that you can access these files via \\?\ is beside the point; you'll end up with files that can't be accessed by most other applications.

But #4736 was closed as a duplicate of this ticket. Perhaps #4736 should be reopened in order to focus on the Unicode issue.

11

  Changed 2 years ago by exarkun

  • description modified (diff)

12

follow-up: ↓ 14   Changed 2 years ago by exarkun

#4736 was just a bad ticket. I would have closed it as invalid instead of as a duplicate.

If someone wants to work on the issue of unicode paths separately from the other issues described on this ticket, file a new ticket for it. As James pointed out though, there is some work in the branch associated with this ticket which addresses unicode issues.

13

  Changed 2 years ago by zooko

  • cc zooko@… added

I created #5203 (FilePath.children() should return FilePath objects with unicodes in them instead of strs) to track a specific feature that we could use. Also to publish a small novel about Tahoe-LAFS and filename handling.

14

in reply to: ↑ 12 ; follow-up: ↓ 15   Changed 22 months ago by davidsarah

Replying to exarkun:

#4736 was just a bad ticket. I would have closed it as invalid instead of as a duplicate. If someone wants to work on the issue of unicode paths separately from the other issues described on this ticket, file a new ticket for it. As James pointed out though, there is some work in the branch associated with this ticket which addresses unicode issues.

Er, what branch? I don't see anything linked from the Branch field. Am I looking in the wrong place?

15

in reply to: ↑ 14   Changed 22 months ago by glyph

  • branch set to /branches/win-filepath-2366-2

Replying to davidsarah:

Replying to exarkun:

#4736 was just a bad ticket. I would have closed it as invalid instead of as a duplicate. If someone wants to work on the issue of unicode paths separately from the other issues described on this ticket, file a new ticket for it. As James pointed out though, there is some work in the branch associated with this ticket which addresses unicode issues.

Er, what branch? I don't see anything linked from the Branch field. Am I looking in the wrong place?

Some branches predate the auto-branch-field-updater gizmo so you have to go to http://twistedmatrix.com/trac/browser/branches/ and grovel around for the ticket number. I've updated the branch field on this ticket.

Note: See TracTickets for help on using tickets.