Skip to content
This repository was archived by the owner on Feb 20, 2025. It is now read-only.

Commit bbe3f60

Browse files
author
Andrey Helldar
authored
Merge pull request #29 from TheDragonCode/3.x
Added character escaping
2 parents eb8daff + df3663c commit bbe3f60

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"require": {
3232
"php": "^7.3 || ^8.0",
33-
"dragon-code/support": "^5.7",
33+
"dragon-code/support": "^5.8",
3434
"symfony/finder": "^4.0 || ^5.0 || ^6.0"
3535
},
3636
"require-dev": {

src/Services/Stringify.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use DragonCode\Support\Concerns\Makeable;
66
use DragonCode\Support\Facades\Helpers\Boolean;
7+
use DragonCode\Support\Facades\Helpers\Str;
78

89
class Stringify
910
{
@@ -16,9 +17,11 @@ public function get($value): string
1617
return $this->fromBool($value);
1718

1819
case $this->isNumeric($value):
19-
case $this->isString($value):
2020
return $value;
2121

22+
case $this->isString($value):
23+
return $this->fromString($value);
24+
2225
default:
2326
return '';
2427
}
@@ -43,4 +46,13 @@ public function fromBool(bool $value): string
4346
{
4447
return Boolean::convertToString($value);
4548
}
49+
50+
public function fromString(string $value): string
51+
{
52+
if (Str::contains($value, [' ', '#'])) {
53+
return sprintf('"%s"', $value);
54+
}
55+
56+
return $value;
57+
}
4658
}

tests/fixtures/expected/expected

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ MAIL_LOG_CHANNEL=
5757
MAIL_MAILER=smtp
5858
MAIL_PASSWORD=
5959
MAIL_PORT=587
60+
MAIL_SENDMAIL_PATH="/usr/sbin/sendmail -t -i"
6061
MAIL_USERNAME=
6162

6263
MEMCACHED_HOST=127.0.0.1

tests/fixtures/expected/expected-config

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ MAIL_LOG_CHANNEL=
5757
MAIL_MAILER=smtp
5858
MAIL_PASSWORD=
5959
MAIL_PORT=587
60+
MAIL_SENDMAIL_PATH="/usr/sbin/sendmail -t -i"
6061
MAIL_USERNAME=
6162

6263
MEMCACHED_HOST=127.0.0.1

tests/fixtures/source/mail.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
'sendmail' => [
6060
'transport' => 'sendmail',
61-
'path' => '/usr/sbin/sendmail -bs',
61+
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
6262
],
6363

6464
'log' => [

0 commit comments

Comments
 (0)