Skip to content

Commit

Permalink
Release 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsil committed Nov 29, 2023
1 parent 14f80e3 commit acd2a93
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .pdbrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

alias kkk os.system('kill -9 %d' % os.getpid())
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repos:
hooks:
- id: check-added-large-files
- id: check-toml
- id: debug-statements
- id: check-yaml
args:
- --unsafe
Expand Down
2 changes: 1 addition & 1 deletion databasez/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from databasez.core import Database, DatabaseURL

__version__ = "0.6.0"
__version__ = "0.7.0"

__all__ = ["Database", "DatabaseURL"]
11 changes: 8 additions & 3 deletions databasez/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,23 +570,28 @@ def __init__(self, url: typing.Union[str, "DatabaseURL"]):
)

@classmethod
def _sanitize_password(cls, url: URL) -> URL:
def _sanitize_fields(cls, url: URL) -> URL:
"""
Making sure all the passwords are allowed.
"""
password = url.password
if not password or password is None:
return url

username = url.username
if not username or username is None:
return url

quoted_username = quote_plus(username)
quoted_password = quote_plus(password)
url = url._replace(password=quoted_password)
url = url._replace(username=quoted_username, password=quoted_password)
return url

@property
def components(self) -> SplitResult:
if not hasattr(self, "_components"):
raw_url = make_url(self._url)
url = DatabaseURL._sanitize_password(raw_url)
url = DatabaseURL._sanitize_fields(raw_url)
self._components = urlsplit(url.render_as_string(hide_password=False))
return self._components

Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image: postgres:14
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_USER: "postgres"
POSTGRES_USER: "postgres@123*#"
POSTGRES_PASSWORD: "passwsss*1348394#"
POSTGRES_DB: "testsuite"
expose:
Expand All @@ -17,9 +17,9 @@ services:
restart: always
image: mysql:5.7
environment:
MYSQL_USER: "mysql"
MYSQL_PASSWORD: "mysql"
MYSQL_DATABASE: "passwsss*1348394#"
MYSQL_USER: "mysql@123*#"
MYSQL_PASSWORD: "passwsss*1348394#"
MYSQL_DATABASE: "testsuite"
MYSQL_ROOT_PASSWORD: "password"
expose:
- "3306"
Expand Down
7 changes: 7 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## 0.7.0

### Fixed

- `urllib.parse.urlsplit` was causing the password or username from being properly parsed and
split with special characters.

## 0.6.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion tests/test_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
DATABASE_CONFIG_URLS = []
for value in DATABASE_URLS:
raw_url = make_url(value)
url: URL = DatabaseURL._sanitize_password(raw_url)
url: URL = DatabaseURL._sanitize_fields(raw_url)
spliter = urlsplit(url.render_as_string(hide_password=False))
DATABASE_CONFIG_URLS.append(
{
Expand Down

0 comments on commit acd2a93

Please sign in to comment.