diff --git a/resources/views/browse-categories.blade.php b/resources/views/browse-categories.blade.php index 79450f8c..8432016e 100644 --- a/resources/views/browse-categories.blade.php +++ b/resources/views/browse-categories.blade.php @@ -7,6 +7,10 @@ @extends('layouts.nova') @section('content') + @php + $sanitizeHtml = fn (?string $value) => \App\Services\ContentSanitizer::sanitizeRenderedHtml($value ?? ''); + @endphp +
{!! $ct->description ?? '' !!}
+{!! $sanitizeHtml($ct->description) !!}
@php $roots = $categoriesByType[$ct->slug] ?? $ct->rootCategories ?? collect(); @@ -37,7 +41,7 @@ @foreach ($roots as $category){!! $category->description !!}
+{!! $sanitizeHtml($category->description) !!}
Bold and italic with link
'); + + expect($html) + ->toContain('')
+ ->toContain('Bold')
+ ->toContain('italic')
+ ->toContain('toContain('rel="noopener noreferrer nofollow"');
+});
+
+test('sanitizeRenderedHtml strips script tags and event handlers', function () {
+ $html = ContentSanitizer::sanitizeRenderedHtml(' Hello