Skip to content

Commit 5f9e22d

Browse files
committed
fix(core): migration to ensure that only admins can access special pages + gitignore and int type fix
1 parent 87e2fa4 commit 5f9e22d

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ robots.txt
3333

3434
# YesWiki stuff
3535
.env
36+
.php-version
3637
wakka.config.php
3738
info.php
3839
cache/*

includes/YesWiki.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,9 +1373,9 @@ public function parse_size($size)
13731373
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
13741374
if ($unit) {
13751375
// Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
1376-
return intval(round($size * pow(1024, stripos('bkmgtpezy', $unit[0]))));
1376+
return intval(round((int)$size * pow(1024, stripos('bkmgtpezy', $unit[0]))));
13771377
} else {
1378-
return intval(round($size));
1378+
return intval(round((int)$size));
13791379
}
13801380
}
13811381

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use YesWiki\Core\Service\AclService;
4+
use YesWiki\Core\YesWikiMigration;
5+
6+
class SecureEditionOfSpecialPages extends YesWikiMigration
7+
{
8+
protected const SPECIAL_PAGES = [
9+
'BazaR', 'GererSite', 'GererDroits', 'GererThemes', 'GererMisesAJour', 'GererUtilisateurs',
10+
'GererDroitsActions', 'GererDroitsHandlers', 'TableauDeBord',
11+
'PageTitre', 'PageMenuHaut', 'PageRapideHaut', 'PageHeader', 'PageFooter', 'PageCSS', 'PageMenu',
12+
'PageColonneDroite', 'MotDePassePerdu', 'ParametresUtilisateur', 'GererConfig', 'ActuYeswiki', 'LookWiki',
13+
];
14+
15+
public function run()
16+
{
17+
// Ensure that every special page is only editable by admins
18+
foreach ($this::SPECIAL_PAGES as $page) {
19+
$this->getService(AclService::class)->save($page, 'write', '@admins');
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)