Skip to content

Commit e643ee4

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: ignore the cached body when comparing e-mails for equality fix PHP syntax to be compatible with 7.2 and 7.3 [HttpFoundation] Add session ID regex comment [Workflow] Fix typo in MethodMarkingStore Fix CS
2 parents d5c67ce + 8a62b40 commit e643ee4

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,36 @@ public function start()
146146
}
147147

148148
$sessionId = $_COOKIE[session_name()] ?? null;
149+
/*
150+
* Explanation of the session ID regular expression: `/^[a-zA-Z0-9,-]{22,250}$/`.
151+
*
152+
* ---------- Part 1
153+
*
154+
* The part `[a-zA-Z0-9,-]` is related to the PHP ini directive `session.sid_bits_per_character` defined as 6.
155+
* See https://www.php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character.
156+
* Allowed values are integers such as:
157+
* - 4 for range `a-f0-9`
158+
* - 5 for range `a-v0-9`
159+
* - 6 for range `a-zA-Z0-9,-`
160+
*
161+
* ---------- Part 2
162+
*
163+
* The part `{22,250}` is related to the PHP ini directive `session.sid_length`.
164+
* See https://www.php.net/manual/en/session.configuration.php#ini.session.sid-length.
165+
* Allowed values are integers between 22 and 256, but we use 250 for the max.
166+
*
167+
* Where does the 250 come from?
168+
* - The length of Windows and Linux filenames is limited to 255 bytes. Then the max must not exceed 255.
169+
* - The session filename prefix is `sess_`, a 5 bytes string. Then the max must not exceed 255 - 5 = 250.
170+
*
171+
* ---------- Conclusion
172+
*
173+
* The parts 1 and 2 prevent the warning below:
174+
* `PHP Warning: SessionHandler::read(): Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, "-", and "," characters are allowed.`
175+
*
176+
* The part 2 prevents the warning below:
177+
* `PHP Warning: SessionHandler::read(): open(filepath, O_RDWR) failed: No such file or directory (2).`
178+
*/
149179
if ($sessionId && $this->saveHandler instanceof AbstractProxy && 'files' === $this->saveHandler->getSaveHandlerName() && !preg_match('/^[a-zA-Z0-9,-]{22,250}$/', $sessionId)) {
150180
// the session ID in the header is invalid, create a new one
151181
session_id(session_create_id());

src/Symfony/Component/Mime/Email.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ class Email extends Message
4343
private $html;
4444
private $htmlCharset;
4545
private $attachments = [];
46-
private ?AbstractPart $cachedBody = null; // Used to avoid wrong body hash in DKIM signatures with multiple parts (e.g. HTML + TEXT) due to multiple boundaries.
46+
/**
47+
* @var AbstractPart|null
48+
*/
49+
private $cachedBody; // Used to avoid wrong body hash in DKIM signatures with multiple parts (e.g. HTML + TEXT) due to multiple boundaries.
4750

4851
/**
4952
* @return $this
@@ -483,9 +486,7 @@ private function generateBody(): AbstractPart
483486
}
484487
}
485488

486-
$this->cachedBody = $part;
487-
488-
return $part;
489+
return $this->cachedBody = $part;
489490
}
490491

491492
private function prepareParts(): ?array

src/Symfony/Component/Mime/Tests/MessageConverterTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ private function assertConversion(Email $expected)
7676
$expected->html('HTML content');
7777
$converted->html('HTML content');
7878
}
79+
80+
$r = new \ReflectionProperty($expected, 'cachedBody');
81+
$r->setAccessible(true);
82+
$r->setValue($expected, null);
83+
$r->setValue($converted, null);
84+
7985
$this->assertEquals($expected, $converted);
8086
}
8187
}

src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public function getMarking(object $subject): Marking
5858
try {
5959
$marking = $subject->{$method}();
6060
} catch (\Error $e) {
61-
$unInitializedPropertyMassage = sprintf('Typed property %s::$%s must not be accessed before initialization', get_debug_type($subject), $this->property);
62-
if ($e->getMessage() !== $unInitializedPropertyMassage) {
61+
$unInitializedPropertyMessage = sprintf('Typed property %s::$%s must not be accessed before initialization', get_debug_type($subject), $this->property);
62+
if ($e->getMessage() !== $unInitializedPropertyMessage) {
6363
throw $e;
6464
}
6565
}

0 commit comments

Comments
 (0)