Overview
| Artifact ID: | de6df813f6f3a77b322b51379a0cc890f67b4baaabbfa37e95b0509809b23e87 |
|---|---|
| Ticket: | bcd1004104651998d1ae99aa6869e249c0ed0019
A change to the system encoding, a stale cached file FsPath object, and an incorrect result |
| User & Date: | pooryorick on 2019-10-22 14:27:51 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
The ext file system has no concept of "encoding": It names a file exactly the sequence of octets it is handed. In the following script, iso8859-1 is used to create a file, and then that same sequence of octets is obtained using <code>glob</code>. Then an FsPath object created under a different system encoding is created and cached. Later on that FsPath object is used under the original system encoding when it shouldn't be. <code><verbatim> set name 登鸛鵲樓 encoding system iso8859-1 # create an iso8859-1-compatible sequence of octets to name the file by. # They happen to be a string encoded in utf-8, but that's irrelevant. set utf8 [encoding convertto utf-8 $name] set chan [open $utf8 w] puts $chan hello close $chan # lassign [glob -directory [pwd] *$utf8*] fname # A file named by that sequence of octets exists. puts [list iso8859-1 [file exists $fname]] ;#-> 1 encoding system utf-8 # The sequence of octets is now itself converted to utf-8. Such a file does not # exist, and a FsPath object has been cached. So far so good. puts [list utf-8 [file exists $fname]] ;#-> 0 encoding system iso8859-1 # Here the answer here should be 1, but the FsPath object created under a # previous system encoding is used when it shouldn't be. puts [list iso8859-1 [file exists $fname]] ;# -> 0 # Discard the cached FsPath object, causing a new FsPath to be created using # the (currently correct) system encoding. puts [list iso8859-1 {string range} [file exists [string range $fname 0 end]]] ;# -> 1 </verbatim></code> - is_private changed to: "0"
- login: "pooryorick"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "pooryorick"
- subsystem changed to: "37. File System"
- title changed to:
A change to the system encoding, a stale cached file FsPath object, and an incorrect result
- type changed to: "Bug"