Skip to content

Commit d25756e

Browse files
committed
SPLAT-4180 remove comments
1 parent 0af396f commit d25756e

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

bundle/Controller/Resource/Upload.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Contracts\Translation\TranslatorInterface;
2020

2121
use function fclose;
22+
use function filesize;
2223
use function fopen;
2324
use function fread;
2425
use function fseek;
@@ -27,10 +28,9 @@
2728
use function is_array;
2829
use function is_file;
2930
use function is_readable;
30-
use function filesize;
3131
use function preg_match;
32-
use function strrpos;
3332
use function strpos;
33+
use function strrpos;
3434
use function strtolower;
3535
use function substr;
3636

@@ -148,9 +148,6 @@ private function isEncryptedPdf(UploadedFile $file): bool
148148

149149
$fileSize = filesize($path);
150150

151-
// For small PDFs, `head` and `tail` reads can overlap and even fully duplicate the file contents.
152-
// This can re-introduce false positives (e.g. `/Encrypt` in a trailing comment after `%%EOF`).
153-
// In that case, scan the full content once.
154151
if ($fileSize !== false && $fileSize <= 20480) {
155152
$content = (string) fread($fp, $fileSize);
156153
} else {
@@ -168,14 +165,11 @@ private function isEncryptedPdf(UploadedFile $file): bool
168165
return false;
169166
}
170167

171-
// Ignore anything after the last EOF marker (some tools append non-PDF comments/metadata).
172168
$eofPos = strrpos($content, '%%EOF');
173169
if ($eofPos !== false) {
174170
$content = substr($content, 0, $eofPos + 5);
175171
}
176172

177-
// Detect presence of encryption dictionary reference in PDF object context.
178-
// This avoids false positives where `/Encrypt` appears in metadata or trailing comments.
179173
return (bool) preg_match('/\/(?:Encrypt)\s+(\d+|<<)/m', $content);
180174
}
181175
}

0 commit comments

Comments
 (0)