Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Mailer] Fix parsing Dsn with empty user/password#39531

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:4.4fromOskarStark:fix-dsn
Dec 17, 2020

Conversation

@OskarStark
Copy link
Contributor

@OskarStarkOskarStark commentedDec 17, 2020
edited
Loading

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
Ticketsno
LicenseMIT
Doc PRno

While working on a PR for Notifier that user and password would be parsed as an empty string, which is not wrong, but not expected IMO. Thi

scheme://@symfony.com andscheme://:@symfony.com should be a valid scheme with user and passnull

Another fix would be to check for://@ and://:@ and throw anInvalidArgumentException WDYT?

The final solution will then be applied to the Notifier DSN in5.1

apfelbox reacted with thumbs up emoji
@OskarStark
Copy link
ContributorAuthor

Ready to merge from my side 👍

@nicolas-grekasnicolas-grekas added this to the4.4 milestoneDec 17, 2020
@nicolas-grekasnicolas-grekas changed the base branch from5.x to4.4December 17, 2020 08:40
@nicolas-grekasnicolas-grekas changed the title[Mailer] Fix Dsn[Mailer] Fix parsing Dsn with empty user/passwordDec 17, 2020
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Now, I'm wondering why we should do this?
If ppl mess up with their DSN, that's their issue.
And if ppl have the empty string as user/pass, why prevent sending them?

@OskarStark
Copy link
ContributorAuthor

Now, I'm wondering why we should do this?
If ppl mess up with their DSN, that's their issue.
And if ppl have the empty string as user/pass, why prevent sending them?

Let me explain it while using an example from Notifier component based on this code:

/**
* @return SendinblueTransport
*/
publicfunctioncreate(Dsn$dsn):TransportInterface
{
if (!$sender =$dsn->getOption('sender')) {
thrownewIncompleteDsnException('Missing sender.',$dsn->getOriginalDsn());
}
$scheme =$dsn->getScheme();
$apiKey =$this->getUser($dsn);
$host ='default' ===$dsn->getHost() ?null :$dsn->getHost();
$port =$dsn->getPort();
if ('sendinblue' ===$scheme) {
return (newSendinblueTransport($apiKey,$sender,$this->client,$this->dispatcher))->setHost($host)->setPort($port);
}
thrownewUnsupportedSchemeException($dsn,'sendinblue',$this->getSupportedSchemes());
}

We provide agetUser method which should throw an exception if the user isnull (same for password):

protectedfunctiongetUser(Dsn$dsn):string
{
$user =$dsn->getUser();
if (null ===$user) {
thrownewIncompleteDsnException('User is not set.',$dsn->getOriginalDsn());
}
return$user;
}
protectedfunctiongetPassword(Dsn$dsn):string
{
$password =$dsn->getPassword();
if (null ===$password) {
thrownewIncompleteDsnException('Password is not set.',$dsn->getOriginalDsn());
}
return$password;
}

And if it is null we throw an exception, but if it is an empty string this would not bubble up and and empty string in the password could lead to a bad experience.

What I want to achieve with this PR is, that the user who implement this bridge can rely on thegetUser method and get an exception if this is the case. For me its better to handle this here.

@fabpot
Copy link
Member

Thank you@OskarStark.

OskarStark reacted with thumbs up emoji

@fabpotfabpot merged commit72fb034 intosymfony:4.4Dec 17, 2020
@OskarStarkOskarStark deleted the fix-dsn branchDecember 17, 2020 16:58
fabpot added a commit that referenced this pull requestDec 18, 2020
…Stark)This PR was squashed before being merged into the 5.1 branch.Discussion----------[Notifier] Fix parsing Dsn with empty user/password| Q             | A| ------------- | ---| Branch?       | 5.1| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | ---| License       | MIT| Doc PR        | ---Same like#39531, but for Notifier component.I backported the DsnTest from `5.2` to `5.1`Commits-------a80409a [Notifier] Fix parsing Dsn with empty user/password
This was referencedDec 18, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

4 participants

@OskarStark@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp