quote in results and compact HTML dashboard

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

quote in results and compact HTML dashboard

Post by plambrecht »

Hi,

As suggested in another post, I'm looking in to the compact html pages to generate a 'Dashboard'.
Works good, for one bug:
when the result contains a single quote character, the HTML code is corrupted:
Result is : enable 'Translate Macros' on the Test Properties
This causes the jscript portion to get corrupted:
<input type=button class=Bad value="16,67 " onclick="showinfo('Test name: \tDiskDelta:\nStatus: \tBad\nLast reply: \tPlease enable 'Translate Macros' on the Test Properties\nReply: \tPlease enable 'Translate Macros' on the Test Properties\n\nLast test time: \t25/08/2004 11:39:13\nInterval: \t00:10:00\nComment: \tDiskDelta\nTest method: \tShell Script\n\nStatus changed at:\t25/08/2004 11:17:53\nTest by: \tHostMonitor\n')">


Can you replace the ' with \' or do some kind of encoding before the text is displayed ?

thx

Pieter
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Done. Update available at www.ks-soft.net/download/hm461.zip

Also we added new variable %LastReply_CStyle%. If you will need to use JavaScript in some "Custom HTML" report, use %Reply_CStyle% and %LastReply_CStyle% variables instead of %Reply% and %LastReply%. It will help to avoid similar problem.

Regards
Alex
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

Post by plambrecht »

Alex,

I found this a very usefull addition to the macro vars...
However, I found that CSTYLE is not always doing the right thing.
It works fine for java-alert things, but not for HTML text.

Could you add an Reply_HTMLEncode ?
This would encode the special HTML chars...
But... I see one problem:
I have UDV's in my reply's that are translated to <br> and other HTML codes...
So if you implement this option, all my <BR>'s are translated to <BR> what is not good :(
Or would you also add a Reply_DoubleQoute that only replaces the " with "
This one is usefull for the Reply's in report... so that the actual text is retained, but only the problemchar " is fixed...


Or you should start with some kind of functions in the Macro's...
@ToHTML%Reply%@
@ToCStyle%Folder%@
just an idea :-)

regards

Pieter
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

However, I found that CSTYLE is not always doing the right thing.
It works fine for java-alert things, but not for HTML text
It is doing right thing. It is designed for java, not for HTML
Could you add an Reply_HTMLEncode ?
This would encode the special HTML chars...
When HostMonitor generates HTML reports or HTML mail, it translates fields into HTML automatically.
I have UDV's in my reply's that are translated to <br> and other HTML codes...
So if you implement this option, all my <BR>'s are translated to <BR> what is not good
Do you mean some of your scripts uses UDV variable as Reply string? And this UDV variable contains some HTML codes? And... I am not sure I follow you...
What exactly do you want to implement?

Regards
Alex
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

Post by plambrecht »

Alex,
When HostMonitor generates HTML reports or HTML mail, it translates fields into HTML automatically.
does it ?
I get a lot of errors on my pages when my reply contains certain characters like the double quote..
I'm talking about reports here...
Do you mean some of your scripts uses UDV variable as Reply string? And this UDV variable contains some HTML codes?
Yes..
As suggested for the new email-in-html format.... seems to work also for reports :-)

Pieter
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

does it ?
I get a lot of errors on my pages when my reply contains certain characters like the double quote..
I'm talking about reports here...
HostMonitor does not replace double quotes because it should not be a problem... unless... you are using Reply variable for HTML tags?? Please provide more information about problem.

Regards
Alex
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

Post by plambrecht »

Alex,

Double quotes are a problem...

With your own templates, I have issues when a reply containes a double quote...

With the report, you have colored buttons, that you can click that show the current status:
<input type=button class=OutOfSchedule value="%REPLY%" onclick="showinfo('some suff, including %REPLY% and %LASTREPLY%')">

If the reply containes a double quote, the HTML code is messed up...

P.

(Strange that no-one else has this problem....)
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Java works strange...
E.g.
- this code works fine showinfo("test \"nameofthetest\"")
- this code works fine as well showinfo('test \'nameofthetest\'')
but this code does not work showinfo("test \'nameofthetest\'")

I mean, if string is concluded into single quotation marks, we should use \' for single quotation marks inside the string. But \" will not work correctly in this case.
If string is concluded into double quotation marks, we should use \" for double quotation marks inside the string. But \' will not work correctly in this case.
Why? I don't know, may be some bug in script processor...

It means \" and \' cannot be used in the same string. Possible solution: use \042 and \047 codes instead. But it could have some sideeffects, e.g. I am not sure SQL servers will accept such codes in SQL Query....

Regards
Alex
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

Post by plambrecht »

All 3 items work fine with an alert()....

The thing is that a double quote is not escaped in the reply_cstyle...
I'm (and your defautl html templates) use it in a html tag...

Can you add the double quote to be escaped ?

SQL is another issue...
in MySQL a single quote has to be escaped as a \'
in MS-SQL a single quote has to be escaped as 2 signle quotes

thx

P.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

All 3 items work fine with an alert()....
It doesn't work on my system. I tried IE 5.0 and Netscape 7.1. Script Host 5.1 is installed.
What software do you use?
Can you add the double quote to be escaped ?
I prefer to find universal solution that will work for everybody.
SQL is another issue...
in MySQL a single quote has to be escaped as a \'
in MS-SQL a single quote has to be escaped as 2 signle quotes
Yes, I remember. Can we do that after Christmas?

Regards
Alex
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

Post by plambrecht »

I tried them under IE6.1 & Firefox 1.0.. all 3 work fine...
probably a feature of IE5 :-)

Enjoy your Christmas and Newyear !

Pieter
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

H'm, I tried IE 6.00 and Opera 7.54 - browsers do not work with string like ...="showinfo(' test \"nameofthetest\" ')" either.
But string like '...="showinfo(' test "nameofthetest" ')" is interpreted correctly.
Looks like we need another variable that should use HTML rules for some characters (" -> &quot..) and C/Java rules for other characters (#10 -> \n, #8 -> \t, #13 -> \r)...

Happy New Year :-)

Regards
Alex
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Ok, this update should fix the problem: www.ks-soft.net/download/hm494.zip

This is "unofficial" update, means there are some undocumented modifications. It was tested and seems to be working fine but it was not tested much. So, better if you keep your eyes on it for a while.

Regards
Alex
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

Post by plambrecht »

Alex...

Thx for the 3 fixes!
I'll keep my eye on the ODBC logging thing.
For the undocumented features.
what variable should I use for the HTML and SQL encoding ?

Pieter
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Use regular variable %Reply%.
HostMonitor resolves test specific (only) variables according to place where you are using variable:
- HTML report or HTML mail
- SQL Query
- anywhere else

Regards
Alex
Post Reply