[ZBX-3940] newlines stored differently depending on client operating system Created: 2011 Jul 11  Updated: 2019 Dec 10

Status: Open
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: None
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: richlv Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: eol, trivial, validation
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File EOL_from_DB.png    

 Description   

attempt to save map label with some newlines in it and ~ 255 characters in length. frontend complains that it exceeds 255, but it seems that from windows systems newlines are attempted to be stored as \r\n, from non-windows - just \n.

they should be just \n always.

additionally, error message is enclosed both in double and single quotes - that's a bit excessive



 Comments   
Comment by Oleksii Zagorskyi [ 2011 Jul 11 ]

I faced with the "similar" stuff some time ago (for eventlog), and because i'm interesting now.
I'm not sure how to correct check how is EOL stored into DB, but i did some experiments from the different browser-OS.

Label was edited (EOL added-deleted and map is saved) in the Opera under Windows and Iceweasel under Debian several times.
Between every edits i did this check (shell is bash):
echo 'SELECT label FROM `sysmaps_elements` WHERE `selementid` = "31";' | mysql zabbix > test
Every time (label contains newline) i received the same result - see attached picture "EOL_from_DB.png" But result is quite strange - i mean \r\n, maybe it's a bash impact?.

So, i can't confirm difference between windows and non-windows OS. It seems EOL always stored with the \r\n.

Label was (EOL preserved): "first_line
second_line"

Used trunk GUI 1.9.5

I don't know is useful for you all this debugging or not

Comment by richlv [ 2011 Jul 13 ]

hmm. indeed, looks like from linux it saves '0D' (non-converted \r), followed by converted \n ...

Comment by Aleksandrs Saveljevs [ 2011 Jul 15 ]

A related problem that can be dealt with in this issue. Current GUI code has interesting line feed and carriage reload sequences:

$ grepphp '\\n\\r' 
./frontends/php/sysmap.php:228: throw new Exception(S_MAP_SAVE_OPERATION_FAILED."\n\r"); 
./frontends/php/sysmap.php:232: $msg = $e->getMessage()."\n\r"; 
./frontends/php/acknow.php:86: $_REQUEST['message'] .= ($_REQUEST['message'] == '' ? '' : "\n\r") . S_SYS_BULK_ACKNOWLEDGE;

These should be changed to either "\r\n" or "\n".

asaveljevs Still the case in 3.0.0beta1 (trunk) r58018:

$ mgrep php '\\n\\r'                                                                  
./frontends/php/include/classes/import/converters/C10ImportConverter.php:                                       $host['inventory'][$key] .= "\r\n\r\n".$value;
./frontends/php/include/classes/validators/CIPRangeValidator.php:                       $range = trim($range, " \t\n\r");
./frontends/php/tests/unit/include/classes/parsers/CTriggerExpressionTest.php:                  ["{host:key.last(1)}\r\n\r\n+\r\n\r\n1", null, true],
./frontends/php/tests/unit/include/classes/import/converters/C10ImportConverterTest.php:                            'notes' => 'notes'."\r\n\r\n".'device notes',
./frontends/php/tests/unit/include/classes/validators/CIPRangeValidatorTest.php:                        [[], "192.168.1.1-2\t\n\r,\t\n\r192.168.1.2-3"],
./frontends/php/tests/unit/include/classes/validators/CIPRangeValidatorTest.php:                                "192.168.1.1-2\t\n\r,
                192.168.1.2-3",
./frontends/php/sysmap.php:                             throw new Exception(_('Access denied!')."\n\r");
./frontends/php/sysmap.php:                             throw new Exception(_('Map update failed.')."\n\r");
./frontends/php/sysmap.php:                     echo 'alert('.zbx_jsvalue(implode("\n\r", $msg)).');';

zalex_ua Yeah, I recently worked for a task where I had to convert data in mysqldump file.
One of thing I had to resolve is EOL conversion to specific sequence. Here is my internal notes for discovered new lines style in a mysql zabbix database:

\r\n detected in actions settings
\n\r detected in acknowledges and auditlog tables heading “--[BULK ACKNOWLEDGE]--” suffix
\n detected in alerts (where \r\n was originally used)

asaveljevs Will be dealt with in (155) of ZBXNEXT-1263. CLOSED.

Comment by Oleksii Zagorskyi [ 2015 Sep 01 ]

Had to return to this issue once more.
All operations done in Chromium 44.0.2403.107 under Linux, using phpMyadmin 3.5.0

When I edit a row (actions.def_longdata) using an Edit link of a row (opening it's page where I press Go after editing) - then all existing and added EOLs added as CRLF.
But when I use a nice feature, say "in table editing" (when I click on a cell, edit (optionally) it in a popped-up small input field, and then click outside of the cell), even without performing actual edits, all existing EOLs stored as LF only.

Then if open the edited action in zabbix frontend (2.4.5) and click Update (without any edits!) - those LFs again stored as CRLFs.

funny ...

p.s. to check EOL type stored in database I used mysql> select def_longdata from actions where actionid=3 into outfile '/tmp/test'; and viewed the test file in a hex view.

Generated at Sun Apr 06 02:36:42 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.