Giter VIP home page Giter VIP logo

Comments (10)

tbvdm avatar tbvdm commented on August 23, 2024

If I understand you correctly, your point is that the replacement character should not occur in sanitised filenames on Windows. Why?

from sigtop.

3052 avatar 3052 commented on August 23, 2024

because the replacement character is its own, valid character. so unless a user intentionally used that in the user name, then it should be replaced in the output

from sigtop.

tbvdm avatar tbvdm commented on August 23, 2024

Again, why? You seem to assume that the output has to be unambiguous. But that's not a goal here.

from sigtop.

3052 avatar 3052 commented on August 23, 2024

because its a worse representation of the original input. if you were just wanting to replace invalid UTF-8 with replacement characters, you could just do this:

runes := []rune(name) 

but you're also replacing characters:

sigtop/path_windows.go

Lines 58 to 60 in 0c7a8fe

if strings.ContainsRune(rchars, r) || unicode.IsControl(r) {
runes[i] = '_'
}

in which case the replacement character should also be replaced, to signify something is invalid in the original input. otherwise you cant disambiguate from an intentional replacement character and one resulting from invalid UTF-8

from sigtop.

tbvdm avatar tbvdm commented on August 23, 2024

otherwise you cant disambiguate

As I've already told you, unambiguity is not a goal. That would require modifying valid filenames, too. I don't want to do that.

from sigtop.

3052 avatar 3052 commented on August 23, 2024

That would require modifying valid filenames, too.

how is that? my suggestion would only impact input that contains invalid UTF-8

from sigtop.

tbvdm avatar tbvdm commented on August 23, 2024

Suppose f is an invalid filename. Let g := sanitiseFilename(f). Valid filenames are not to be modified, so sanitiseFilename(g) == g. Therefore, sanitiseFilename(f) == sanitiseFilename(g), even though f != g.

from sigtop.

3052 avatar 3052 commented on August 23, 2024

I dont see how that answers the question. a filename with invalid UTF-8 is not valid, so would necessarily need replacement.

from sigtop.

tbvdm avatar tbvdm commented on August 23, 2024

I'm very sorry, but I'm going to close this.

from sigtop.

3052 avatar 3052 commented on August 23, 2024

OK well I tried. if you have a justification why invalid UTF-8 is acceptable for a filename, I would be interested to hear it.

from sigtop.

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.