Skip to content

Commit 2f3b391

Browse files
committed
PDF handler patch.
1 parent 0274ff2 commit 2f3b391

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,7 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
192192
- [2025.10.07]: Added support for NO_COLOR.
193193
- [2025.11.02]: Some minor refactoring.
194194
- [2025.11.21]: Added PHP 8.5 to workflows.
195+
196+
### v3.7.2
197+
198+
- [2026.01.09]: Slightly improved the PDF handler's stream detection.

src/PdfHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Pdf handler (last modified: 2021.10.30).
11+
* This file: Pdf handler (last modified: 2026.01.09).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -63,7 +63,7 @@ public function __construct(string $File)
6363

6464
/** Building object tree. */
6565
$Tree = [];
66-
$Check = preg_match_all('~\n(\d+) (\d+) obj ?\r?\n(.+?) ?\r?\nendobj ?\r?\n~s', $File, $Matches);
66+
$Check = preg_match_all('~\n(\d+) (\d+) obj ?(?:\r?\n|\r\n?)(.+?) ?(?:\r?\n|\r\n?)endobj ?(?:\r?\n|\r\n?)~s', $File, $Matches);
6767
if ($Check && isset($Matches, $Matches[0], $Matches[0][0])) {
6868
$Count = count($Matches[0]);
6969
for ($Iterator = 0; $Iterator < $Count; $Iterator++) {
@@ -72,7 +72,7 @@ public function __construct(string $File)
7272
'Generation Number' => $Matches[2][$Iterator],
7373
'Data' => $Matches[3][$Iterator]
7474
];
75-
if (preg_match('~(.*)stream ?\r?\n(.+) ?\r?\nendstream~s', $Tree[$Iterator]['Data'], $SubMatches)) {
75+
if (preg_match('~(.*)stream ?(?:\r?\n|\r\n?)(.+) ?(?:\r?\n|\r\n?)endstream~s', $Tree[$Iterator]['Data'], $SubMatches)) {
7676
$Tree[$Iterator]['Stream'] = trim($SubMatches[2]);
7777
$Tree[$Iterator]['Data'] = trim($SubMatches[1]);
7878
}

0 commit comments

Comments
 (0)