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

Error with CACHE_URL passwords that end with '=' #200

Closed
davidfischer opened this issue Sep 13, 2018 · 5 comments
Closed

Error with CACHE_URL passwords that end with '=' #200

davidfischer opened this issue Sep 13, 2018 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@davidfischer
Copy link

This is somewhat similar to #194. A cache password that ends with the = character raises an error when calling env.cache. Even escaping it (%3D) will not work.

It looks like the cast method works by trying to just convert to a value and if that fails with a ValueError, it assumes the value is string (see code). However, a string that ends in a = will throw a SyntaxError instead of a ValueError:

>>> import ast
>>> ast.literal_eval('mypassword=')
Traceback (most recent call last):
...
SyntaxError: unexpected EOF while parsing

If you think the solution is just to catch a SyntaxError in addition to a ValueError, I'm happy to make a PR.

Normally I'd just change the password but on Azure the generated cache passwords always end with a = for some reason.

@ksze
Copy link

ksze commented Apr 9, 2019

on Azure the generated cache passwords always end with a = for some reason

The "=" is often used as a padding character at the end of base64-encoded strings. Is the password really just the base64 of a long array of random bytes?

@davidfischer
Copy link
Author

Correct.

tkdchen pushed a commit to tkdchen/django-environ that referenced this issue Oct 6, 2019
Revert "add configuration as suggested from @blueyed"
@pix666
Copy link

pix666 commented Feb 21, 2020

A few more examples for which a SyntaxError exception is raised by _cast(). Escaping does not help.

  • anything- (minus at the end)
  • anything* (asterisk at the end)
  • *anything (asterisk at the start)
  • anything. (dot at the end)
  • anything.1 (dot near digit)
  • (anything (unbalanced braces anywhere)
  • anything-v1.2 (God knows why. For some reason anything-1.2 works well)

I came across this when I tried to set the value of key_prefix for Redis.

@sergeyklay sergeyklay self-assigned this Aug 30, 2021
@sergeyklay
Copy link
Collaborator

Possible related #288 (comment)

I'll try to sort out

sergeyklay added a commit that referenced this issue Sep 7, 2021
@sergeyklay sergeyklay added the bug Something isn't working label Sep 7, 2021
sergeyklay added a commit that referenced this issue Sep 7, 2021
@sergeyklay
Copy link
Collaborator

This is resolved in develop branch. Thank you for the report, and for helping us make django-environ better. And I am sorry about the delay.

gcf-merge-on-green bot pushed a commit to GoogleCloudPlatform/python-docs-samples that referenced this issue Sep 14, 2021
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [django-environ](https://django-environ.readthedocs.org) ([source](https://togithub.com/joke2k/django-environ), [changelog](https://django-environ.readthedocs.org/en/latest/changelog.html)) | `==0.6.0` -> `==0.7.0` | [![age](https://badges.renovateapi.com/packages/pypi/django-environ/0.7.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/django-environ/0.7.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/django-environ/0.7.0/compatibility-slim/0.6.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/django-environ/0.7.0/confidence-slim/0.6.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>joke2k/django-environ</summary>

### [`v0.7.0`](https://togithub.com/joke2k/django-environ/blob/master/CHANGELOG.rst#v070---11-September-2021)

[Compare Source](https://togithub.com/joke2k/django-environ/compare/v0.6.0...v0.7.0)

Added
\+++++

-   Added support for negative float strings
    `#&#8203;160 <https://github.com/joke2k/django-environ/issues/160>`\_.
-   Added Elasticsearch5 to search scheme
    `#&#8203;297 <https://github.com/joke2k/django-environ/pull/297>`\_.
-   Added Elasticsearch7 to search scheme
    `#&#8203;314 <https://github.com/joke2k/django-environ/issues/314>`\_.
-   Added the ability to use `bytes` or `str` as a default value for `Env.bytes()`.

Fixed
\+++++

-   Fixed links in the documentation.
-   Use default option in `Env.bytes()`
    `#&#8203;206 <https://github.com/joke2k/django-environ/pull/206>`\_.
-   Safely evaluate a string containing an invalid Python literal
    `#&#8203;200 <https://github.com/joke2k/django-environ/issues/200>`\_.

Changed
\+++++++

-   Added 'Funding' and 'Say Thanks!' project urls on pypi.
-   Stop raising `UserWarning` if `.env` file isn't found. Log a message with
    `INFO` log level instead `#&#8203;243 <https://github.com/joke2k/django-environ/issues/243>`\_.

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/python-docs-samples).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants