Skip to content

Commit 815c8ca

Browse files
deemonicclaude
andcommitted
fix: validate UTF-8 input before regex matching
Ensures invalid UTF-8 strings are sanitized before reaching preg_match with the /u flag, preventing silent regex failures. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 57fa14a commit 815c8ca

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/BlaspService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ public function check(string $string): self
257257
throw new Exception('No string to check');
258258
}
259259

260+
if (!mb_check_encoding($string, 'UTF-8')) {
261+
$string = mb_convert_encoding($string, 'UTF-8', 'UTF-8');
262+
}
263+
260264
$this->sourceString = $string;
261265

262266
$this->cleanString = $string;

0 commit comments

Comments
 (0)