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

Keep newline/tab escapes in quoted strings (fix certificate serializing) #296

Merged
merged 4 commits into from
Sep 14, 2021

Conversation

johnbergvall
Copy link
Contributor

Change parsing of quoted strings to not remove \ before \r, \n and \t to allow basic formatting and certificate serializing.

Also include optional \r in delimiter when splitting string to multiple lines for better compatibility with PEM-certificates and MIME-headers

Example certificate data
VAR="---BEGIN---\r\n---END---"
now becomes
r"---BEGIN---\r\n---END---"
instead of
r"---BEGIN---rn---END---"

This makes linebreaks work correctly with Env().str('VAR', multiline=True) as well

@sergeyklay
Copy link
Collaborator

PR was closed by mistake. Reopened it.

johnbergvall and others added 4 commits September 14, 2021 19:34
Keep escape backslash for newline/tab characters. Parsing still
differs from shell syntax but keeps string structure intact.

Example certificate data
    VAR="---BEGIN---\r\n---END---"
now becomes
    "---BEGIN---\r\n---END---"
instead of
    "---BEGIN---rn---END---"
@johnbergvall
Copy link
Contributor Author

I've rebased this onto the latest develop and included your changes from sergeyklay/django-environ-2#29

@sergeyklay sergeyklay self-requested a review September 14, 2021 19:22
@sergeyklay sergeyklay self-assigned this Sep 14, 2021
@sergeyklay sergeyklay added the enhancement New feature or request label Sep 14, 2021
@sergeyklay
Copy link
Collaborator

I'll review this PR ASAP. Thank you for the contributing!

@coveralls
Copy link

coveralls commented Sep 14, 2021

Coverage Status

Coverage decreased (-0.1%) to 89.823% when pulling 6080f4d on johnbergvall:develop into 3bb8e6e on joke2k:develop.

Copy link
Collaborator

@sergeyklay sergeyklay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@sergeyklay sergeyklay merged commit 78b8a03 into joke2k:develop Sep 14, 2021
@sergeyklay
Copy link
Collaborator

Merged! Thank you for the patch, and for helping us make django-environ better.

sergeyklay added a commit that referenced this pull request Sep 15, 2021
…ng) (#296)

Limit backslash escape removal for quoted newlines

Keep escape backslash for newline/tab characters. Parsing still
differs from shell syntax but keeps string structure intact.

Example certificate data
    VAR="---BEGIN---\r\n---END---"
now becomes
    "---BEGIN---\r\n---END---"
instead of
    "---BEGIN---rn---END---"

Co-authored-by: Serghei Iakovlev <egrep@protonmail.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants