Skip to content

Adds proper escaping for php service config format #15766

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

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

faizanakram99
Copy link
Contributor

php configs need \\\\, \\ are not enough.

"service('App\\Mailer')" compiles into AppMailer , "service('App\\\\Mailer')" compiles correctly into App\Mailer

@faizanakram99 faizanakram99 changed the base branch from 5.4 to 5.3 August 31, 2021 09:49
@faizanakram99 faizanakram99 requested a review from xabbuh as a code owner August 31, 2021 09:49
@faizanakram99 faizanakram99 changed the base branch from 5.3 to 4.4 August 31, 2021 09:49
@faizanakram99 faizanakram99 changed the base branch from 4.4 to 5.3 August 31, 2021 09:52
@faizanakram99 faizanakram99 changed the base branch from 5.3 to 5.4 August 31, 2021 09:52
@@ -67,7 +67,7 @@ to another service: ``App\Mailer``. One way to do this is with an expression:
$services->set(MailerConfiguration::class);

$services->set(Mailer::class)
->args([expr("service('App\\Mail\\MailerConfiguration').getMailerMethod()")]);
->args([expr("service('App\\\\Mail\\\\MailerConfiguration').getMailerMethod()")]);
Copy link
Member

Choose a reason for hiding this comment

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

The result is so ugly and confusing, that we might think of adding a comment explaining this. Example:

$services->set(Mailer::class)
    // because of the escaping applied by PHP, you must add 4 backslashes for each original backslash
    ->args([expr("service('App\\\\Mail\\\\MailerConfiguration').getMailerMethod()")]);

@javiereguiluz javiereguiluz added this to the 4.4 milestone Sep 3, 2021
php configs need `\\\\`, `\\` are not enough.

`"service('App\\Mailer')"` compiles into `AppMailer` ,  `"service('App\\\\Mailer')"` compiles correctly into `App\Mailer`
@javiereguiluz javiereguiluz changed the base branch from 5.4 to 4.4 September 3, 2021 09:02
@javiereguiluz javiereguiluz merged commit b5f1dca into symfony:4.4 Sep 3, 2021
@javiereguiluz
Copy link
Member

Faizan, thanks and congrats on your first Symfony Docs contribution 🎉

@faizanakram99 faizanakram99 deleted the patch-1 branch September 3, 2021 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants