Skip to content

Commit 655fe6c

Browse files
committed
lowercase animal names. fixes #94
1 parent a8e36c3 commit 655fe6c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

_test/helper.test.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ public function validationProvider()
2424
['ant44lion', true],
2525
['44', true],
2626

27+
['aNt', false],
28+
['anT.Lion', false],
29+
['ant.Lion.cow', false],
30+
['ant-Lion', false],
31+
['ant-Lion.cow', false],
32+
['4aNt', false],
33+
['aNt4', false],
34+
['ant44Lion', false],
35+
2736
['ant.', false],
2837
['.ant', false],
2938
['ant-', false],

admin/new.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use chrisbliss18\phpico\PHPIco;
44
use dokuwiki\Extension\AdminPlugin;
55
use dokuwiki\Form\Form;
6+
use dokuwiki\Utf8\PhpString;
67
use splitbrain\RingIcon\RingIcon;
78

89
/**
@@ -139,7 +140,7 @@ protected function validateAnimalData()
139140
{
140141
global $INPUT;
141142

142-
$animalname = $INPUT->filter('trim')->str('animalname');
143+
$animalname = $INPUT->filter('trim')->filter([PhpString::class, 'strtolower'])->str('animalname');
143144
$adminsetup = $INPUT->str('adminsetup');
144145
$adminpass = $INPUT->filter('trim')->str('adminPassword');
145146
$template = $INPUT->filter('trim')->str('animaltemplate');

helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function checkFarmSetup()
130130
*/
131131
public function validateAnimalName($animalname)
132132
{
133-
return preg_match("/^[a-z0-9]+([\\.\\-][a-z0-9]+)*$/i", $animalname) === 1;
133+
return preg_match("/^[a-z0-9]+([\\.\\-][a-z0-9]+)*$/", $animalname) === 1;
134134
}
135135

136136
/**

0 commit comments

Comments
 (0)