Comments (6)
A secure filename sanitizer may worth a separate crate. It may be full of heuristics and tweaks (like "no unicode + abbreviate + supplement with a short hash" or "please make a 8.3 filename")
from app-dirs-rs.
Not currently handled, but would be a great (and simple) addition.
It looks like any name starting with those values and a period are also invalid.
from app-dirs-rs.
If sanitized
is indented to be used for security, this would be a necessary addition.
It should probably stated in the documentation whether the function is expected to be secure (there may be even advisories about it in this case) or not. Transforming a hostile string into a filename (secure to use, but still mostly representing the string in question) is a hard-ish task.
Does it chop off too long filename by the way?
from app-dirs-rs.
The intent wasn't security, but to make sure that e.g. somebody developing on Linux wouldn't accidentally use path names that fail on Windows.
We call sanitized
on every platform for the sake of consistency, but I'll probably handle the "reserved" names on Windows only (to avoid a breaking change, since those names would fail on Windows anyway).
from app-dirs-rs.
The intent wasn't security
Then either the scope and intent should be enlarged to include uses for security (e.g. the name is 100% guranteed to be "no tricks"), or phrase like "the function should not be used for security, to sanitize hostile user input" or "it is possible that sanitized
returns a tricky filename on some platforms".
Maybe the latter better suits the purpose of this library, as the former may require building and maintaining blacklists of names per various platforms and may be more (not autorun.inf
, not .git
and so on).
from app-dirs-rs.
Agreed; I can add a clarification to the docs. It definitely isn't intended to be used on user input, but programmer input - to create a directory structure for their app data in the right place.
from app-dirs-rs.
Related Issues (20)
- Consider using SHGetKnownFolderPath on Windows
- Add detailed table of paths to the docs
- Consider doing something smarter with XDG multi-paths HOT 3
- Use P: AsRef<Path> instead of &str for path parameter
- UserData on Windows should be local.
- Store data correctly on Windows.
- Make `AppInfo` own its strings. HOT 9
- Rename functions HOT 1
- Add temporary directory HOT 3
- Allow using the XDG dirs on macOS. HOT 2
- Add option to enable author property on *nix
- use the new winapi 0.3 HOT 2
- Type of this value must be known in this context on 1.25.0-nightly HOT 12
- get_app_dir creates directories despite the documentation saying otherwise
- Disable author ? HOT 1
- Use proper path types
- AppInfo stores strings incorrectly HOT 1
- Add fallback implementation
- AppDirsError doesn't implement the Error trait
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from app-dirs-rs.