Code Monkey home page Code Monkey logo

Comments (6)

vi avatar vi commented on September 26, 2024 2

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.

andybarron avatar andybarron commented on September 26, 2024

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.

vi avatar vi commented on September 26, 2024

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.

andybarron avatar andybarron commented on September 26, 2024

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.

vi avatar vi commented on September 26, 2024

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.

andybarron avatar andybarron commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.