Merge branch 'v0.26'
This commit is contained in:
commit
421dd93ffd
9 changed files with 89 additions and 4 deletions
|
@ -765,6 +765,12 @@ class EntityRepo
|
|||
$scriptElem->parentNode->removeChild($scriptElem);
|
||||
}
|
||||
|
||||
// Remove data or JavaScript iFrames
|
||||
$badIframes = $xPath->query('//*[contains(@src, \'data:\')] | //*[contains(@src, \'javascript:\')]');
|
||||
foreach ($badIframes as $badIframe) {
|
||||
$badIframe->parentNode->removeChild($badIframe);
|
||||
}
|
||||
|
||||
// Remove 'on*' attributes
|
||||
$onAttributes = $xPath->query('//@*[starts-with(name(), \'on\')]');
|
||||
foreach ($onAttributes as $attr) {
|
||||
|
|
|
@ -146,7 +146,12 @@ class UserController extends Controller
|
|||
]);
|
||||
|
||||
$user = $this->userRepo->getById($id);
|
||||
$user->fill($request->all());
|
||||
$user->fill($request->except(['email']));
|
||||
|
||||
// Email updates
|
||||
if (userCan('users-manage') && $request->filled('email')) {
|
||||
$user->email = $request->get('email');
|
||||
}
|
||||
|
||||
// Role updates
|
||||
if (userCan('users-manage') && $request->filled('roles')) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
|
3
public/uploads/.gitignore
vendored
3
public/uploads/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
*
|
||||
!.gitignore
|
||||
!.gitignore
|
||||
!.htaccess
|
1
public/uploads/.htaccess
Executable file
1
public/uploads/.htaccess
Executable file
|
@ -0,0 +1 @@
|
|||
Options -Indexes
|
|
@ -1,6 +1,7 @@
|
|||
<input type="text" id="{{ $name }}" name="{{ $name }}"
|
||||
@if($errors->has($name)) class="text-neg" @endif
|
||||
@if(isset($placeholder)) placeholder="{{$placeholder}}" @endif
|
||||
@if(isset($disabled) && $disabled) disabled="disabled" @endif
|
||||
@if(isset($tabindex)) tabindex="{{$tabindex}}" @endif
|
||||
@if(isset($model) || old($name)) value="{{ old($name) ? old($name) : $model->$name}}" @endif>
|
||||
@if($errors->has($name))
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div>
|
||||
@if($authMethod !== 'ldap' || userCan('users-manage'))
|
||||
<label for="email">{{ trans('auth.email') }}</label>
|
||||
@include('form.text', ['name' => 'email'])
|
||||
@include('form.text', ['name' => 'email', 'disabled' => !userCan('users-manage')])
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -80,6 +80,7 @@ class PageContentTest extends TestCase
|
|||
$page->save();
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertDontSee($script);
|
||||
$pageView->assertSee('abc123abc123');
|
||||
}
|
||||
|
@ -103,12 +104,42 @@ class PageContentTest extends TestCase
|
|||
$page->save();
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', '<script>');
|
||||
$pageView->assertElementNotContains('.page-content', '</script>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function test_iframe_js_and_base64_urls_are_removed()
|
||||
{
|
||||
$checks = [
|
||||
'<iframe src="javascript:alert(document.cookie)"></iframe>',
|
||||
'<iframe SRC=" javascript: alert(document.cookie)"></iframe>',
|
||||
'<iframe src="data:text/html;base64,PHNjcmlwdD5hbGVydCgnaGVsbG8nKTwvc2NyaXB0Pg==" frameborder="0"></iframe>',
|
||||
'<iframe src=" data:text/html;base64,PHNjcmlwdD5hbGVydCgnaGVsbG8nKTwvc2NyaXB0Pg==" frameborder="0"></iframe>',
|
||||
|
||||
];
|
||||
|
||||
$this->asEditor();
|
||||
$page = Page::first();
|
||||
|
||||
foreach ($checks as $check) {
|
||||
$page->html = $check;
|
||||
$page->save();
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', '<iframe>');
|
||||
$pageView->assertElementNotContains('.page-content', '</iframe>');
|
||||
$pageView->assertElementNotContains('.page-content', 'src=');
|
||||
$pageView->assertElementNotContains('.page-content', 'javascript:');
|
||||
$pageView->assertElementNotContains('.page-content', 'data:');
|
||||
$pageView->assertElementNotContains('.page-content', 'base64');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function test_page_inline_on_attributes_removed_by_default()
|
||||
{
|
||||
$this->asEditor();
|
||||
|
@ -118,6 +149,7 @@ class PageContentTest extends TestCase
|
|||
$page->save();
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertDontSee($script);
|
||||
$pageView->assertSee('<p>Hello</p>');
|
||||
}
|
||||
|
@ -130,6 +162,7 @@ class PageContentTest extends TestCase
|
|||
'<div>Lorem ipsum dolor sit amet.<p onclick="console.log(\'test\')">Hello</p></div>',
|
||||
'<div><div><div><div>Lorem ipsum dolor sit amet.<p onclick="console.log(\'test\')">Hello</p></div></div></div></div>',
|
||||
'<div onclick="console.log(\'test\')">Lorem ipsum dolor sit amet.</div><p onclick="console.log(\'test\')">Hello</p><div></div>',
|
||||
'<a a="<img src=1 onerror=\'alert(1)\'> ',
|
||||
];
|
||||
|
||||
$this->asEditor();
|
||||
|
@ -140,6 +173,7 @@ class PageContentTest extends TestCase
|
|||
$page->save();
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', 'onclick');
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,43 @@ class RolesTest extends BrowserKitTest
|
|||
$this->actingAs($this->user)->visit('/')->dontSee($usersLink);
|
||||
}
|
||||
|
||||
public function test_user_cannot_change_email_unless_they_have_manage_users_permission()
|
||||
{
|
||||
$userProfileUrl = '/settings/users/' . $this->user->id;
|
||||
$originalEmail = $this->user->email;
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->visit($userProfileUrl)
|
||||
->assertResponseOk()
|
||||
->seeElement('input[name=email][disabled]');
|
||||
$this->put($userProfileUrl, [
|
||||
'name' => 'my_new_name',
|
||||
'email' => 'new_email@example.com',
|
||||
]);
|
||||
$this->seeInDatabase('users', [
|
||||
'id' => $this->user->id,
|
||||
'email' => $originalEmail,
|
||||
'name' => 'my_new_name',
|
||||
]);
|
||||
|
||||
$this->giveUserPermissions($this->user, ['users-manage']);
|
||||
|
||||
$this->visit($userProfileUrl)
|
||||
->assertResponseOk()
|
||||
->dontSeeElement('input[name=email][disabled]')
|
||||
->seeElement('input[name=email]');
|
||||
$this->put($userProfileUrl, [
|
||||
'name' => 'my_new_name_2',
|
||||
'email' => 'new_email@example.com',
|
||||
]);
|
||||
|
||||
$this->seeInDatabase('users', [
|
||||
'id' => $this->user->id,
|
||||
'email' => 'new_email@example.com',
|
||||
'name' => 'my_new_name_2',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_user_roles_manage_permission()
|
||||
{
|
||||
$this->actingAs($this->user)->visit('/settings/roles')
|
||||
|
|
Loading…
Reference in a new issue