Skip to content

Environment variables with URLs are incorrectly encoded with escape sequences (e.g., ':' becomes '\x3a') #248468

@SoheilNK

Description

@SoheilNK

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.100.0
  • OS Version: Linux

Description

After updating to VS Code version 1.100.0, environment variables containing URLs are incorrectly encoded with escape sequences in the terminal environment. This causes issues with applications that parse these URLs, particularly in Django applications where CORS and CSRF settings require properly formatted URLs.

Steps to Reproduce

  1. Open VS Code version 1.100.0 on Linux
  2. Set environment variables containing URLs in your VS Code settings or launch.json, for example:
    {
      "env": {
        "FRONTEND_HOST": "http://localhost:5173",
        "BACKEND_HOST": "http://localhost:8000"
      }
    }
  3. Open a terminal in VS Code and run env | grep HOST
  4. Observe that the colon characters in the URLs are escaped as \x3a

Expected Behavior

Environment variables containing URLs should preserve the exact format that was specified, including colons and other special characters, without escaping them.

Actual Behavior

The colon characters (:) in URLs are being escaped as \x3a, causing issues with applications that require properly formatted URLs. For example, Django rejects these malformed URLs in CSRF_TRUSTED_ORIGINS and CORS_ALLOWED_ORIGINS settings.

Example output when running env | grep HOST:

FRONTEND_HOST=http\x3a//localhost\x3a5173
BACKEND_HOST=http\x3a//localhost\x3a8000

Environment

  • VS Code Version: 1.100.0
  • OS: Linux
  • Python Extensions Installed:
    • Python (ms-python.python)
    • Pylance (ms-python.vscode-pylance)
    • GitHub Copilot (github.copilot)

Workaround

Use a script to manually fix the environment variables before running the application:

import os
os.environ['FRONTEND_HOST'] = 'http://localhost:5173'
os.environ['BACKEND_HOST'] = 'http://localhost:8000'

Additional Information

This issue causes Django applications to fail with errors such as:

(4_0.E001) As of Django 4.0, the values in the CSRF_TRUSTED_ORIGINS setting must start with a scheme (usually http:// or https://) but found http\x3a//localhost\x3a5173.
(corsheaders.E013) Origin 'http\\x3a//localhost\\x3a5173' in CORS_ALLOWED_ORIGINS is missing scheme or netloc

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugcandidateIssue identified as probable candidate for fixing in the next releaseregressionSomething that used to work is now brokenterminal-processProblems launching processes, managing ptys, exiting, process leaks, etc.verifiedVerification succeeded

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions