mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-04 21:35:47 -05:00
minor fixes
This commit is contained in:
@@ -40,15 +40,17 @@
|
||||
{{ $extensionHead }}
|
||||
@show
|
||||
|
||||
{{-- @json escapes < > & ' " so a stored value such as "<!--<script" cannot
|
||||
change how the browser parses these inline scripts. --}}
|
||||
@section('user-data')
|
||||
@if(!is_null(Auth::user()))
|
||||
<script>
|
||||
window.PterodactylUser = {!! json_encode(Auth::user()->toVueObject()) !!};
|
||||
window.PterodactylUser = @json(Auth::user()->toVueObject());
|
||||
</script>
|
||||
@endif
|
||||
@if(!empty($siteConfiguration))
|
||||
<script>
|
||||
window.SiteConfiguration = {!! json_encode($siteConfiguration) !!};
|
||||
window.SiteConfiguration = @json($siteConfiguration);
|
||||
</script>
|
||||
@endif
|
||||
@show
|
||||
|
||||
@@ -49,6 +49,15 @@ test('guests load extension bundles with only their public frontend settings', f
|
||||
->assertDontSee('frontend-config-marker', false)
|
||||
->assertDontSee('secret-config-marker', false);
|
||||
})->with(['/auth/login', '/']);
|
||||
test('setting values cannot change how the inline bootstrap script is parsed', function (): void {
|
||||
$hostile = '</script><!--<script>&\'"';
|
||||
$this->app->make(ExtensionRepository::class)->settings('config-probe')->set('registration', $hostile);
|
||||
|
||||
$html = (string) $this->get('/auth/login')->assertOk()->assertSee('"id":"config-probe"', false)->getContent();
|
||||
|
||||
expect($html)->not->toContain('<!--<script')->not->toContain('</script><!--')
|
||||
->toContain('"registration":'.json_encode($hostile, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_THROW_ON_ERROR));
|
||||
});
|
||||
test('guests of an extension without public settings receive an empty config', function (): void {
|
||||
$repository = $this->app->make(ExtensionRepository::class);
|
||||
$this->app->make(ExtensionSettingsRegistry::class)->register('config-probe', new ExtensionSettingsDefinition($repository->settings('config-probe'), [
|
||||
|
||||
Reference in New Issue
Block a user