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

Only trim the leading slash from the DSN if a host is also available #6790

Open
wants to merge 2 commits into
base: 4.2.x
Choose a base branch
from

Conversation

TimWolla
Copy link

Q A
Type improvement
Fixed issues #6789

Summary

Previously the DsnParser unconditionally removed the first character from the path, without verifying that it is actually a slash and that it is dealing with a reasonably well-formed URI. This causes confusing behavior when a malformed URI that survives parse_url() is passed to parse(), since DsnParser would return the input as the dbname, but with the first character missing.

This can lead to hard-to-debug situations when the DSN is coming from an environment variable, where quoting characters are accidentally included in the value itself, instead of being interpreted by the tool setting the env, since the dbname almost looks like the intended input (but still having the trailing quote).

see #6789

Previously the DsnParser unconditionally removed the first character from the
path, without verifying that it is actually a slash and that it is dealing with
a reasonably well-formed URI. This causes confusing behavior when a malformed
URI that survives `parse_url()` is passed to `parse()`, since DsnParser would
return the input as the `dbname`, but with the first character missing.

This can lead to hard-to-debug situations when the DSN is coming from an
environment variable, where quoting characters are accidentally included in the
value itself, instead of being interpreted by the tool setting the env, since
the `dbname` almost looks like the intended input (but still having the
trailing quote).

see doctrine#6789
`normalizeDatabaseUrlPath()` is only ever called if a `host` is available,
which means that the path needs to start with a slash. Replace the `if()` by an
`assert()` to satisfy Codecov.
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.

1 participant