Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting Escape Sequences #711

Open
bd82 opened this issue Jan 26, 2023 · 1 comment · May be fixed by #713
Open

Supporting Escape Sequences #711

bd82 opened this issue Jan 26, 2023 · 1 comment · May be fixed by #713

Comments

@bd82
Copy link

bd82 commented Jan 26, 2023

Hello @motdotla and thank you for creating dotenv nodejs library 👍

Feature Request

Could dotenv nodejs library support escape sequences (e.g \" \t) ?

At the minimum can it be aligned with the Ruby dotenv library?

Would a PR which aligns with the Ruby library be welcome?

Context

I've noticed some implementations of dotenv support character escapes and some do not.
Also there does not seem to be an official specification anywhere for dotenv.
This is causing issues when we need to use the same .env files in multiple runtimes.

Is the Ruby library the original implementation and thus also used as the pseudo specification?

Examples of escape handling in different dotenv libraries

Ruby Library

  • Supports escaping anything other than $
  • Only interpret values of \n and \r and only in double quoted strings.
  • Relevant Source Code

Elixir Library escaping specs

  • Seems to allow expanding of more special sequences versus the Ruby library, e.g: \t and \f
  • Does not seem to distinguish (at the spec level at least) between single or double quotes escape values.

Python Library

  •    Allowed escape sequences:
    
      in single-quoted values: \\, \'
      in double-quoted values: \\, \', \", \a, \b, \f, \n, \r, \t, \v
    
@bd82 bd82 changed the title Escape Sequences Supporting Escape Sequences Jan 26, 2023
@bd82 bd82 linked a pull request Feb 2, 2023 that will close this issue
@ritschwumm
Copy link

interestingly, the LINE regexp already does understand backslashed in front of single quote, double quote and backtick...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants