Skip to content

Commit 94c5f41

Browse files
committed
MySQL : protection longueurs catégories
1 parent 5af7c47 commit 94c5f41

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/models/Category.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public function addCategory ($valuesTmp) {
9595

9696
$values = array (
9797
$valuesTmp['id'],
98-
$valuesTmp['name'],
99-
$valuesTmp['color'],
98+
substr($valuesTmp['name'], 0, 255),
99+
substr($valuesTmp['color'], 0, 7),
100100
);
101101

102102
if ($stm && $stm->execute ($values)) {

public/install.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
define ('SQL_REQ_CAT', 'CREATE TABLE IF NOT EXISTS `%scategory` (
1414
`id` char(6) NOT NULL,
1515
`name` varchar(255) NOT NULL,
16-
`color` varchar(7) NOT NULL,
16+
`color` char(7) NOT NULL,
1717
PRIMARY KEY (`id`),
1818
INDEX (`name`)
1919
);');
@@ -26,7 +26,7 @@
2626
`website` varchar(255) NOT NULL,
2727
`description` varchar(1023) NOT NULL,
2828
`lastUpdate` int(11) NOT NULL,
29-
`priority` tinyint NOT NULL DEFAULT \'10\',
29+
`priority` tinyint(2) NOT NULL DEFAULT \'10\',
3030
`pathEntries` varchar(511) DEFAULT NULL,
3131
`httpAuth` varchar(511) DEFAULT NULL,
3232
`error` boolean NOT NULL DEFAULT \'0\',

0 commit comments

Comments
 (0)