Skip to content

fix(parser): support bash-style single-quote splices in values#633

Open
simoncraf wants to merge 1 commit intotheskumar:mainfrom
simoncraf:fix/single-quote-splice
Open

fix(parser): support bash-style single-quote splices in values#633
simoncraf wants to merge 1 commit intotheskumar:mainfrom
simoncraf:fix/single-quote-splice

Conversation

@simoncraf
Copy link

Summary

This PR adds support for bash-style single-quote splices inside .env values.

Before this change, python-dotenv failed to parse values like:

VAR='I'"'"'m a student'

Even though this is valid Bash and evaluates to:

I'm a student

After this change, python-dotenv accepts that form and parses it correctly.

Closes #544

What changed

  • Added support for the '"'"' splice pattern while parsing single-quoted values
  • Kept existing \' handling unchanged
  • Added parser-level coverage for the new form
  • Added dotenv_values coverage for the same behaviour

Example

This now works:

a='b'"'"'c'

and is parsed as:

b'c

Notes

This change is intentionally narrow in scope.

It does not try to implement general shell-style concatenation. It only supports the specific splice form commonly used in Bash to embed a literal single quote inside an otherwise single-quoted string.

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 this pull request may close these issues.

python-dotenv cannot parse valid bash value with a single quote "escaped" inside single quotes

1 participant