inconsistent output when using % signs

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

inconsistent output when using % signs

Post by jssingh »

Hi,

I have some output that is killing the JSON when it has % signs, which seemed odd to me that percent signs alone would kill the JSON, so I decided to test it out and the output I'm getting is wildly inconsistent (but interesting). In the examples below, I see the output correctly in the HTML page (cgi-bin/extinfo.cgi). The first one is the example of when it works correctly.

Input:
Group Share% Use

JSON Output:
"Group Share% Use"

Input:
Group Share% Use% Share

JSON Output:
"Group Share% Use�����hare"

Input:
Group Share% Use% hare

JSON Output:
"Group Share% Use 0x0.000300000003p-1022re"

Input:
Group 90%

JSON Output:
""

Input:
Testing % sign

JSON Output:
"Testing `֞ign"


Any ideas? I'm using commit 6081644, but I had this problems with % signs when I was using 4.0.4 and 4.0.7 (the release from last week).
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: inconsistent output when using % signs

Post by abrist »

I opened an issue on github: https://github.com/NagiosEnterprises/na ... e/issues/4
There is a chance that the % signs are not escaped correctly in the cgis. Eric[0] or Eric[1] should respond here or on github rather soon.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
estanley
Posts: 19
Joined: Thu Apr 08, 2010 9:28 am

Re: inconsistent output when using % signs

Post by estanley »

Thanks again for reporting issues with the JSON CGI. Andy is correct that the percent signs were not being escaped. Commit 04c80dd appears to resolve this issue. I've tested each of the cases you listed and they now display correctly. Please test the commit and let us know whether it works for you.
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

Re: inconsistent output when using % signs

Post by jssingh »

I tested it with the live data and everything shows up perfectly. Thank you!

a side note: a coworker suggested that I try the HTML code for percent signs:

Code: Select all

%
and that broke things even worse!, but this commit fixes that issue as well.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: inconsistent output when using % signs

Post by tmcdonald »

Thanks for the feedback! Closing up.
Former Nagios employee
Locked