Skip to content

Commit d2e2606

Browse files
authored
Fix XSS in /feed (#4218)
1 parent 33dc575 commit d2e2606

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

app/Actions/RSS/Generate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use App\Services\UrlGenerator;
2121
use Carbon\Exceptions\InvalidFormatException;
2222
use Carbon\Exceptions\UnitException;
23+
use GrahamCampbell\Markdown\Facades\Markdown;
2324
use Illuminate\Contracts\Container\BindingResolutionException;
2425
use Illuminate\Support\Carbon;
2526
use Illuminate\Support\Collection;
@@ -54,7 +55,7 @@ private function toFeedItem(object $data): FeedItem
5455
$feed_item = [
5556
'id' => $page_link,
5657
'title' => $data->title,
57-
'summary' => $data->description ?? '',
58+
'summary' => Markdown::convert($data->description ?? '')->getContent(),
5859
'updated' => $this->asDateTime($data->updated_at),
5960
'link' => $page_link,
6061
'enclosure' => $this->url_generator->pathToUrl($data->short_path, $data->storage_disk, SizeVariantType::ORIGINAL),
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
/**
4+
* SPDX-License-Identifier: MIT
5+
* Copyright (c) 2017-2018 Tobias Reich
6+
* Copyright (c) 2018-2026 LycheeOrg.
7+
*/
8+
9+
use Illuminate\Database\Migrations\Migration;
10+
use Illuminate\Support\Facades\Artisan;
11+
use Illuminate\Support\Facades\DB;
12+
use Symfony\Component\Console\Output\ConsoleOutput;
13+
use Symfony\Component\Console\Output\ConsoleSectionOutput;
14+
15+
return new class() extends Migration {
16+
private ConsoleOutput $output;
17+
private ConsoleSectionOutput $msg_section;
18+
19+
public function __construct()
20+
{
21+
$this->output = new ConsoleOutput();
22+
$this->msg_section = $this->output->section();
23+
}
24+
25+
/**
26+
* Run the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function up(): void
31+
{
32+
DB::table('configs')->where('key', 'version')->update(['value' => '070503']);
33+
try {
34+
Artisan::call('cache:clear');
35+
} catch (\Throwable $e) {
36+
$this->msg_section->writeln('<error>Warning:</error> Failed to clear cache for version 7.5.3');
37+
38+
return;
39+
}
40+
$this->msg_section->writeln('<info>Info:</info> Cleared cache for version 7.5.3');
41+
}
42+
43+
/**
44+
* Reverse the migrations.
45+
*
46+
* @return void
47+
*/
48+
public function down(): void
49+
{
50+
DB::table('configs')->where('key', 'version')->update(['value' => '070502']);
51+
}
52+
};

resources/views/vendor/feed/json.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929
],
3030
@endif
31-
"tags": [ {!! implode(',', array_map(fn($c) => '"'.$c.'"', $item->category)) !!} ]
31+
"tags": @json($item->category)
3232
}@if($item !== $items->last()),
3333
@endif
3434
@endforeach

version.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.5.2
1+
7.5.3

0 commit comments

Comments
 (0)