dimaryaz opened a new issue, #5446:
URL: https://github.com/apache/arrow-rs/issues/5446

   **Describe the bug**
   Suppose I have a file name with a special character such as `%.txt`. When 
percent-encoded, it would be `%25.txt`. What is the correct way to represent it 
using a `Path` object?
   
   The following three all produce the same result, with `Path::raw` value 
being the un-encoded `%.txt` - which seems to indicate that is the expected 
behavior:
   ```
   let p1 = Path::from_url_path("%25.txt").unwrap();
   let p2 = Path::parse("%.txt").unwrap();
   let p3 = Path::from_filesystem_path("%.txt").unwrap();  // if it actually 
exists
   ```
   The third one in particular implies that there should not be any encoding 
done (otherwise, it will fail to find the file).
   
   However, `Path::from("%.txt")` _will_ percent-encode its input (and it is 
even documented), resulting in the "raw" value being `%25.txt`. In fact, there 
is no possible value that could be passed into `Path::from` to create a `Path` 
object for the `%.txt` file.
   
   What this means is:
   - `Path::from` is inconsistent with the other APIs
   - Because of the `From` trait, it is easy to call it by accident by using 
e.g. `"%.txt".into()`
   - There is really no use case for it, since other APIs treat the "raw" value 
as the original, not percent-encoded value
   
   Therefore, I believe this is a bug in the API.
   
   **To Reproduce**
   Call `Path::from("%.txt")`.
   
   **Expected behavior**
   Should produce the "raw" value of `%.txt`, not `%25.txt`.
   
   **Additional context**
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to