Ad Widget

Collapse

Plain Text line wrapping.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • traq911
    Junior Member
    • May 2005
    • 17

    #1

    Plain Text line wrapping.

    I've been gathering 'top' data and storing it as plain text. I've built a screen with a plain text cell that looked like this:



    In Zabbix 1.4.x it now looks like this:



    Is there any reason "plain text" parsing does not break on carriage returns in screen tables anymore?
    Attached Files
  • rolandsym
    Member
    • Jul 2007
    • 76

    #2
    trying with windows

    hi,
    I'm trying to do the same with a vbs script in windows but I get truncated by 255 characters. I wanted to do what you had setup on the screen pane with generated command info.

    Rolandsym

    Comment

    • Alexei
      Founder, CEO
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Sep 2004
      • 5654

      #3
      It is fixed in pre 1.4.2!
      Alexei Vladishev
      Creator of Zabbix, Product manager
      New York | Tokyo | Riga
      My Twitter

      Comment

      • traq911
        Junior Member
        • May 2005
        • 17

        #4
        Looks like the problem is back in 1.6.0

        I just upgraded to 1.6 and am now getting a single line of text again. It a little different this time though. The end of lines are actually marked with the html tag <br>.

        Comment

        • Aly
          ZABBIX developer
          • May 2007
          • 1126

          #5
          I you sure that string it self does not contain html tags?
          Zabbix | ex GUI developer

          Comment

          • traq911
            Junior Member
            • May 2005
            • 17

            #6
            Using Unix top command

            The string I'm collecting is generated from the Unix top command. I don't think it's generating HTML tags

            Comment

            • rwa
              Junior Member
              • Oct 2008
              • 9

              #7
              I ran into this same issue, also from unix output (ps). The basic flow of data getting onto a screen is:

              screen.php -> screen.inc.php

              on line 373 of screen.inc.php a string value like this is formatted with:

              Code:
              $value = nl2br(nbsp(htmlspecialchars($row["value"])));
              which is fine b/c the nl2br is added outside of the htmlspecialchars function, so the <br /> that nl2br inserts for a newline is not encoded by htmlspecialchars.

              The flow is then:

              line 384 of screen.inc.php -> AddRow function of the CTable class in ctable.inc.php -> PrepareRow function of the CTable class in ctable.inc.php -> AddItem function of the CRow class in ctable.inc.php -> AddItem function of CTag class in ctag.inc.php

              on line 107 of ctag.inc.php you have

              Code:
              array_push($this->items,str_replace(array('<','>','"'),array('&lt;','&gt;','&quot;'),$value));
              and it is this which then effectively html encodes the <br /> tags added above and causes the text to render the multiple lines as one long line.

              I don't know in what situations this is actually useful (so text would get here w/o passing through the first encoding step), so I don't want to just remove it (though that works for this particular case). What I changed it to was:

              Code:
              array_push($this->items,str_replace('&lt;br /&gt;', '<br />', str_replace(array('<','>','"'),array('&lt;','&gt;','&quot;'),$value)));
              which just adds an additional replace searching for encoded <br /> tags and reverts them to unencoded ones. This would still break in a situation where:

              1) your text has <br /> tags in it
              2) it does not pass through the first encoding step that this path does

              In that case line 107 would encode them but my change would unencode them. For us this shouldn't be an issue as no data we capture is html, but someone that really knows what they are doing could probably fix this better.

              Thanks.

              Comment

              • radamand
                Member
                • Aug 2008
                • 89

                #8
                I am having the same problem; I have an item that queries several lines of text out of a MySQL database and stores it as plain text, when I insert this into a screen it has a bunch of "<br />" inserted in it, and the screen shows each poll of data on a single line, where it should be showing several lines of data just from the last poll.

                wrong:
                Unlimited space to host images, easy to use image uploader, albums, photo hosting, sharing, dynamic image resizing on web and mobile.


                what it should look like: (image is taken from Latest Data -> History)
                Unlimited space to host images, easy to use image uploader, albums, photo hosting, sharing, dynamic image resizing on web and mobile.
                Last edited by radamand; 22-10-2008, 23:20.

                Comment

                • Aly
                  ZABBIX developer
                  • May 2007
                  • 1126

                  #9
                  Hmm no one sad that this problem is in the Screens page...

                  P.S. well changeing this line:
                  PHP Code:
                  $value nl2br(nbsp(htmlspecialchars($row["value"]))); 
                  to this:
                  PHP Code:
                  $value zbx_nl2br(nbsp(htmlspecialchars($row["value"]))); 
                  Should help.
                  Last edited by Aly; 23-10-2008, 10:00.
                  Zabbix | ex GUI developer

                  Comment

                  • radamand
                    Member
                    • Aug 2008
                    • 89

                    #10
                    not to pick nits, but, the original poster did;

                    "Is there any reason "plain text" parsing does not break on carriage returns in screen tables anymore?"
                    but, thanks for the fix, works great!

                    and thanks for a great tool!
                    Last edited by radamand; 23-10-2008, 17:14.

                    Comment

                    • radamand
                      Member
                      • Aug 2008
                      • 89

                      #11
                      ack, problem with that fix...

                      Screen shot
                      Last edited by radamand; 23-10-2008, 19:08.

                      Comment

                      • Aly
                        ZABBIX developer
                        • May 2007
                        • 1126

                        #12
                        Originally posted by radamand
                        ack, problem with that fix...

                        Screen shot
                        I see...

                        PHP Code:
                                            $value nbsp(htmlspecialchars($row['value']));
                                            
                        $value zbx_nl2br($value); 
                        Zabbix | ex GUI developer

                        Comment

                        • radamand
                          Member
                          • Aug 2008
                          • 89

                          #13
                          That fixed it, thanks again!

                          Comment

                          Working...