Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  2. ZBXNEXT-5299

Decoding HTML for macros/variables in web scenarios


      In web scenarios it is possible to extract data returned from a webpage in to a variable which is used in a later step.

      What is not possible is to html decode the webpage data, to be able to post this back later.


      For example using the following HTTP response:


      <form method="POST" name="hiddenform" action="https://opac.stpeters.school.nz:443/">
      <input type="hidden" name="wctx" value="rm=0&amp;id=passive&amp;ru=%2f" /><noscript><p>Script is disabled. Click Submit to continue.</p><input type="submit" value="Submit" /></noscript>
      <script language="javascript">window.setTimeout('document.forms[0].submit()', 0);</script>



      It is possible to extract out the form action and the value of the wctx input:

      {action}=regex:<form .action="([^"])"



      The problem is when in a following step I try to post back wctx, the POST data appears as:


      which is invalid.


      Currently there are the macro functions {{macro}.urlencode()} and {{macro}.urldecode()} which will URL encode and decode (https://www.zabbix.com/documentation/4.2/manual/web_monitoring) a string.

      There are also the macro functions  {{macro}.regsub(<pattern>,<output>)} and {{macro}.iregsub(<pattern>,<output>)} which do regular expression substitutions, however these are not supported against web scenario variables (https://www.zabbix.com/documentation/4.2/manual/config/macros/macro_functions).


      Hence this request is for two new macro functions: {{macro}.htmlencode()} and {{macro}.htmldecode()}.  These functions would HTML escape special characters in macros and remove the escaping respectably. A list of characters to be escaped can be found at http://www.htmlhelp.com/reference/html40/entities/special.html


      The following forum post also discusses the exact issue I’m having and the reason for requesting these functions: https://www.zabbix.com/forum/zabbix-help/51074-html-entities-in-web-scenario


      A related but not identical feature request is: ZBXNEXT-4452 Edit macro variables values extracted from web page in successive POST request using function "replace(<what>,<to_what>)"

            sboidenko Sergejs Boidenko
            Tracyb Tracy Briscoe
            Team A
            3 Vote for this issue
            3 Start watching this issue