-
-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Description
Root cause:
while ($result[0] === '.') { // ERROR: No length check
$result = substr($result, 1);
}Problem: Code accesses $result[0] without checking if string has content, causing errors when processing empty capture groups.
Reproduction:
use Phiki\Phiki;
use Phiki\Theme\Theme;
$phiki = new Phiki();
$code = '@if (ViewData.Model.Count == 0) { <!-- No-data placeholder with \"New Standard +\" button --> } else { <tr> <th>Standard <span class=\"caretDwn\"></span></th> <!-- ... other headers ... --> </tr> @foreach (var standard in Model) { <tr id=\"@standard.Uid\" class=\"@rowClass hand\" ...> <td><a href=\"@navigateScript\">@standard.Title</a></td> <!-- ... other columns ... --> </tr> } } ';
$html = $phiki->codeToHtml($code, 'html', [
'light' => Theme::CatppuccinMocha,
'dark' => Theme::CatppuccinMocha,
])->toString();
// Throws: local.ERROR: Uninitialized string offset 0 {"code":"@if (ViewData.Model.Count == 0) { <!-- No-data placeholder with \\\"New Standard +\\\" button --> } else { <tr> <th>Standard <span class=\\\"caretDwn\\\"></span></th> <!-- ... other headers ... --> </tr> @foreach (var standard in Model) { <tr id=\\\"@standard.Uid\\\" class=\\\"@rowClass hand\\\" ...> <td><a href=\\\"@navigateScript\\\">@standard.Title</a></td> <!-- ... other columns ... --> </tr> } } ","language":"html"} Possible fix:
while (!empty($result) && $result[0] === '.') {
$result = substr($result, 1);
}Environment:
- PHP 8.4.11
- Laravel 12.25.0
- Phiki 2.0.0-beta4
Seems to be related with some "@" or on html lang
Metadata
Metadata
Assignees
Labels
No labels