vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.63k stars 26.93k forks source link

[Env]: Issue with Parsing `$` Symbol in .env Files #59957

Open Innei opened 10 months ago

Innei commented 10 months ago

Link to the code that reproduces this issue

https://github.com/Innei/next-env-symbol-reproduction

To Reproduce

  1. run dev

Current vs. Expected behavior

  1. current .env file is
RAW_SYMBOL='111$11111'
WITH_SYMBOL=111$11111

The first one is wrapped in single quotes, and the env should not be added to the variable in the terminal. The second one should be inserted into the variable

But currently, all of this is like the second one.

CleanShot 2023-12-27 at 5  08 02@2x

  1. Expected, only parsed the second one, instead of the first.

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020
Binaries:
  Node: 20.8.1
  npm: 10.2.4
  Yarn: 1.22.19
  pnpm: 8.11.0
Relevant Packages:
  next: 14.0.4
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Additional context

No response

xairoo commented 10 months ago

I have the same, so annoying! Tried to connect to my MongoDB and found out, that Next.js removes the string from $ until &

mongodb://foobar:xxxx$willgetremovedincludedollarsign&worksfine@example.com...

Sometimes it feels like a pain to use a strong password.

Anyway, the $ can be escaped \$

AmagiDDmxh commented 1 day ago

do double quote "" help to avoid this?