Skip to content

Commit a4022ce

Browse files
authored
fix: Escape app title and tag title on list pages CVE-2022-47968 (#1088)
1 parent cd07d47 commit a4022ce

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

resources/views/items/list.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<tr>
3333
<td>{{ $app->title }}</td>
3434
<td><a href="{{ $app->url }}">{{ $app->link }}</a></td>
35-
<td class="text-center"><a{{ $app->target }} href="{!! route('items.edit', [$app->id]) !!}" title="{{ __('app.settings.edit') }} {!! $app->title !!}"><i class="fas fa-edit"></i></a></td>
35+
<td class="text-center"><a{{ $app->target }} href="{!! route('items.edit', [$app->id]) !!}" title="{{ __('app.settings.edit') }} {{ $app->title }}"><i class="fas fa-edit"></i></a></td>
3636
<td class="text-center">
3737
{!! Form::open(['method' => 'DELETE','route' => ['items.destroy', $app->id],'style'=>'display:inline']) !!}
3838
<button class="link" type="submit"><i class="fa fa-trash-alt"></i></button>

resources/views/items/scripts.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
}
3232
});
3333
// initial load
34-
$('#tile-preview .title').html($('#appname').val());
34+
$('#tile-preview .title').text($('#appname').val());
3535
$('#tile-preview .item').css('backgroundColor', $('#appcolour').val());
3636
$('#tile-preview .app-icon').attr('src', $('#appimage img').attr('src'));
3737
3838
// Updates
3939
$('#appname').on('keyup change', function(e) {
40-
$('#tile-preview .title').html($(this).val());
40+
$('#tile-preview .title').text($(this).val());
4141
})
4242
$('#apptype').on('change', function(e) {
4343
appload($(this).find('option:selected').val());
@@ -178,7 +178,7 @@ function appload(appvalue) {
178178
if($('#appname').val() === '') {
179179
$('#appname').val(data.name)
180180
}
181-
$('#tile-preview .title').html($('#appname').val());
181+
$('#tile-preview .title').text($('#appname').val());
182182
if(data.custom != null) {
183183
$.get(base+'view/'+data.custom, function(getdata) {
184184
$('#sapconfig').html(getdata).show();

resources/views/tags/list.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<tr>
3232
<td>{{ $app->title }}</td>
3333
<td><a{{ $app->target }} href="{{ url($app->link) }}">{{ $app->link }}</a></td>
34-
<td class="text-center"><a href="{!! route('tags.edit', [$app->id]) !!}" title="{{ __('app.settings.edit') }} {!! $app->title !!}"><i class="fas fa-edit"></i></a></td>
34+
<td class="text-center"><a href="{!! route('tags.edit', [$app->id]) !!}" title="{{ __('app.settings.edit') }} {{ $app->title }}"><i class="fas fa-edit"></i></a></td>
3535
<td class="text-center">
3636
{!! Form::open(['method' => 'DELETE','route' => ['tags.destroy', $app->id],'style'=>'display:inline']) !!}
3737
<button class="link" type="submit"><i class="fa fa-trash-alt"></i></button>

tests/Feature/ItemListTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,15 @@ public function test_displays_items_on_the_item_list_page()
3131
$response->assertSee('Item 2');
3232
$response->assertSee('Item 3');
3333
}
34+
35+
public function test_escapes_xss_on_the_item_list_page()
36+
{
37+
$this->addItemWithTitleToDB('<script>alert("XSS")</script>');
38+
39+
$response = $this->get('/items');
40+
41+
$response->assertStatus(200);
42+
$response->assertDontSee('<script>alert("XSS")</script>', false);
43+
$response->assertSee('<script>alert("XSS")</script>');
44+
}
3445
}

tests/Feature/TagListTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,15 @@ public function test_displays_the_tags_on_the_tag_list_page()
3232
$response->assertSee('Tag 2');
3333
$response->assertSee('Tag 3');
3434
}
35+
36+
public function test_escapes_xss_on_the_tag_list_page()
37+
{
38+
$this->addTagWithTitleToDB('<script>alert("XSS")</script>');
39+
40+
$response = $this->get('/tags');
41+
42+
$response->assertStatus(200);
43+
$response->assertDontSee('<script>alert("XSS")</script>', false);
44+
$response->assertSee('<script>alert("XSS")</script>');
45+
}
3546
}

0 commit comments

Comments
 (0)