mirror of
https://github.com/filp/whoops.git
synced 2026-09-13 03:06:20 +00:00
Allow URIs in frame comments
This commit is contained in:
@@ -101,8 +101,20 @@ class PrettyPageHandler extends Handler
|
||||
$v->tables = array_merge($this->getDataTables(), $v->tables);
|
||||
|
||||
call_user_func(function() use($templateFile, $v) {
|
||||
// $e -> cleanup output
|
||||
$e = function($_) { return htmlspecialchars($_, ENT_QUOTES, 'UTF-8'); };
|
||||
// $e -> cleanup output, optionally preserving URIs as anchors:
|
||||
$e = function($_, $allowLinks = false) {
|
||||
$escaped = htmlspecialchars($_, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
// convert URIs to clickable anchor elements:
|
||||
if($allowLinks) {
|
||||
$escaped = preg_replace(
|
||||
'@([A-z]+?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@',
|
||||
"<a href=\"$1\" target=\"_blank\">$1</a>", $escaped
|
||||
);
|
||||
}
|
||||
|
||||
return $escaped;
|
||||
};
|
||||
|
||||
// $slug -> sluggify string (i.e: Hello world! -> hello-world)
|
||||
$slug = function($_) {
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
<?php extract($comment) ?>
|
||||
<div class="frame-comment" id="comment-<?php echo $i . '-' . $commentNo ?>">
|
||||
<span class="frame-comment-context"><?php echo $e($context) ?></span>
|
||||
<?php echo $e($comment) ?>
|
||||
<?php echo $e($comment, true) ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user