Code Monkey home page Code Monkey logo

Comments (6)

danharrin avatar danharrin commented on July 21, 2024 1

Yeah, .env format is a very hard to completely master, especially since it even differs between PHP and JS slightly. I will remove the magic, it will get really bloated otherwise.

from envault.

danharrin avatar danharrin commented on July 21, 2024 1

Hey, I just released v1.3.3 that disables quote removal when importing variables.

from envault.

danharrin avatar danharrin commented on July 21, 2024

Hi, thanks for highlighting this issue.

It's actually intentional behaviour that double quotes get removed when you import. They should then added back when you sync with the NPX command. This abstraction ensures formatting consistency, as some people may forget to use them when they should, and some may use them when they shouldn't.

I admit that I had not thought of doing this with single quotes as well, and it should also happen when you add a variable on its own. I will work on getting this sorted.

Apart from values that contain a , can you think of anything else in the value that needs escaping in this way?

from envault.

mbalandis avatar mbalandis commented on July 21, 2024

@danharrin thanks for confirmation. I will continues using it and see how it goes. Dw too much about it. If I find a situation where it is causing a problem I'll let you know.

Single quotes theoretically could be part of the string within FOO="'BAR'" a .env so if import something like FOO='BAR' would it then sync as FOO="'BAR'" or remove it? It is very unlikely/rare case but what about handling "" within '' ? Ex: FOO='"BAR"'. Not sure if anyone would have some kind of long text in description that contains multiple types of quotes or a bearer token with ' or " :) What would happen if I import FOO="BAR" it adds as FOO=BAR, I edit the value quote it myself and it becomes FOO="BAR" and then run a command which makes it FOO="BAR" then it technically should be FOO='"BAR"' or FOO="\"BAR\"" (maybe I want the quotes for whatever reason).

Even though I appreciate the magic that sanitizes the variables on npx command, I am not certain it would handle every rule of dot env. Last time I checked the variables that get unquoted and not needed to be quoted are left unquoted so it basically removes the manual quotes I had it .env (I tend to quote strings regardless) but it did leave quotes where it needs it.

from envault.

danharrin avatar danharrin commented on July 21, 2024

I do see what you're saying. Should we remove the magic and have quotes manually applied? I just feel that there are so many edge cases that we would probably never get it completely perfect.

from envault.

mbalandis avatar mbalandis commented on July 21, 2024

I do see what you're saying. Should we remove the magic and have quotes manually applied? I just feel that there are so many edge cases that we would probably never get it completely perfect.

Yea, I understand. I could say you could have magic sanitize as an option but with a choice not to use it (in .env) but whether or not that makes code more bloated or not and whether it is worth it. Or like you said let user handle it. There is a date format I use that in php dot env in laravel failed when it IS double quote but doesn't when it is single or unquoted: FORMAT="Ymd\THis" this fails in date, gmdate or/and Carbon but doesnt if it is FORMAT='Ymd\THis' or FORMAT=Ymd\THis. It is like a situation where I just want T to be T and not timezone abbreviation. Ex: 20200510T1000000

from envault.

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.