You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2011-05-27 15:44:36

Maska
Member
Registered: 2009-07-17
Posts: 13

Bug: doesn't add ticket when the char №70 is a new line

When users try to add a new ticket where no title, and in description char 70 is the new line is SQL-error and the new ticket isn't added.
The problem in regular expressions to convert the description in the title.

File inc/ticket.class.php:

      // No name set name
      if (empty($input["name"])) {
         $input["name"] = preg_replace('/\r\n/',' ',$input['content']);
         $input["name"] = preg_replace('/\n/',' ',$input['name']);
         $input["name"] = utf8_substr($input['name'],0,70);
      }

For example, add a ticket with the following description:

123456789012345678901234567890123456789012345678901234567890123456789<new line>

Before if we have in string $input['content'] (length 73):

123456789012345678901234567890123456789012345678901234567890123456789\r\n

After if in $input["name"]:

123456789012345678901234567890123456789012345678901234567890123456789\

Of course, this line causes an error when adding to the database. This error is observed in the current version (0.78.5) and previous.

Regular expressions are used now do not work for strings, when the \r\n is 4 symbols, they are written for strings in which \r\n is 1 char.
Example of fix, we changed the following lines:

      // No name set name
      if (empty($input["name"])) {
         $input["name"] = preg_replace('/\\\r\\\n/',' ',$input['content']);
         $input["name"] = preg_replace('/\\\n/',' ',$input['name']);
         $input["name"] = utf8_substr($input['name'],0,70);
      }

Please fix it.

P.S. Please, delete topic http://www.glpi-project.org/forum/viewt … p?id=24193 it error posted in the wrong forum.

Offline

#2 2011-06-06 11:24:34

Maska
Member
Registered: 2009-07-17
Posts: 13

Re: Bug: doesn't add ticket when the char №70 is a new line

This error also in version 0.80.

File files/_log/sql-errors.log:

06-06-2011 13:18 [346@server]
*** MySQL query error : 
***
SQL: INSERT
                   INTO `glpi_tickets` (`date`,`due_date`,`entities_id`,`suppliers_id_assign`,`status`,`type`,`urgency`,`ticketcategories_id`,`impact`,`itemtype`,`priority`,`requesttypes_id`,`name`,`content`,`id`,`users_id_lastupdater`,`users_id_recipient`,`global_validation`,`items_id`,`actiontime`,`date_mod`) VALUES (\'2011-06-06 13:16:00\',NULL,\'0\',\'0\',\'assign\',\'1\',\'3\',\'0\',\'3\',\'\',\'3\',\'1\',\'123456789012345678901234567890123456789012345678901234567890123456789\\\',\'123456789012345678901234567890123456789012345678901234567890123456789\\r\\n\',\'0\',\'346\',\'346\',\'none\',0,0,\'2011-06-06 13:18:12\')
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '123456789012345678901234567890123456789012345678901234567890123456789\r\n','0','' at line 2
Backtrace :
/home/helpdesk/glpi/inc/commondbtm.class.php&nbsp;:355          DBmysql->query()
/home/helpdesk/glpi/inc/commondbtm.class.php&nbsp;:665          CommonDBTM->addToDB()
/home/helpdesk/glpi/front/ticket.form.php&nbsp;:59              CommonDBTM->add()
/home/helpdesk/glpi/front/ticket.form.php

Offline

Board footer

Powered by FluxBB