diff --git a/migration/19.12/1912.sql b/migration/19.12/1912.sql index b52123fbfe94615c9e5f1846ce95b2f5d59b9fd4..a2e3adb2188f72df22ee55a3bd742f0831b09e3f 100644 --- a/migration/19.12/1912.sql +++ b/migration/19.12/1912.sql @@ -301,6 +301,7 @@ UPDATE usergroups_services SET service_id = 'manage_tags_application' WHERE serv /* REFACTORING MODIFICATION */ ALTER TABLE notif_email_stack ALTER COLUMN attachments TYPE text; +ALTER TABLE tags ALTER COLUMN label TYPE character varying(128); /* REFACTORING SUPPRESSION */ diff --git a/sql/structure.sql b/sql/structure.sql index a514746b4a8e92adc5754153322892c8715ab858..811f453fd8c2953d6c3135cf4dfacb08b388bfb6 100755 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -1059,7 +1059,7 @@ WITH (OIDS=FALSE); CREATE TABLE tags ( id serial NOT NULL, - label character varying(50) NOT NULL, + label character varying(128) NOT NULL, entity_id_owner character varying(32), CONSTRAINT tags_id_pkey PRIMARY KEY (id) ) diff --git a/src/app/tag/controllers/TagController.php b/src/app/tag/controllers/TagController.php index ccf72474aea65b05456fdce28ac7d680318a9842..f39220960ca71fc5007e92c3d527ceccf54fe063 100644 --- a/src/app/tag/controllers/TagController.php +++ b/src/app/tag/controllers/TagController.php @@ -63,6 +63,10 @@ class TagController return $response->withStatus(400)->withJson(['errors' => 'Body label is empty or not a string']); } + if (!Validator::length(1, 128)->validate($body['label'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body label has more than 128 characters']); + } + $id = TagModel::create([ 'label' => $body['label'] ]); @@ -88,13 +92,16 @@ class TagController return $response->withStatus(400)->withJson(['errors' => 'Route id must be an integer val']); } - $body = $request->getParsedBody(); if (!Validator::stringType()->notEmpty()->validate($body['label'])) { return $response->withStatus(400)->withJson(['errors' => 'Body label is empty or not a string']); } + if (!Validator::length(1, 128)->validate($body['label'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body label has more than 128 characters']); + } + TagModel::update([ 'set' => [ 'label' => $body['label']