VictoriaMetrics/app
Aliaksandr Valialkin a018b1d75e
app/vmalert/templates: properly escape all the special chars in quotesEscape function
Previously the `quotesEscape` function was escaping only double quotes.
This wasn't enough, since the input string could contain other special chars,
which must be escaped when put inside JSON string. For example, carriage return and line feed chars (\n\r),
backslash char, etc. This led to the following issues, which were improperly fixed:

- https://github.com/VictoriaMetrics/VictoriaMetrics/issues/890 - this issue
  was "fixed" by introducing the `crlfEscape` function, which led to unnecessary
  complications in user templates, while not fixing various corner cases
  such as backslash chars in the input string.
  See 1de15ad490

- https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3139 - this issue
  was "fixed" by urlencoding the whole string passed to -external.alert.source
  command-line flag. This led to invalid urls, which couldn't be parsed by Grafana.
  See 00c838353d
  and 4bd0244599

This commit properly encodes the input string passed to `quotesEscape`, so it can be safely embedded inside JSON strings.

This commit deprecates crlfEscape template function and adds the following new template functions:

- strvalue and stripDomain - these functions are supported by Prometheus, so they were added
  for compatibility purposes.
- jsonEscape and htmlEscape for converting the input string to valid quoted JSON string
  and for html-escaping the input string, so it could be safely embedded as a plaintext
  into html.

This commit also documents all supported template functions at https://docs.victoriametrics.com/vmalert.html#template-functions
The deprecated crlfEscape function isn't documented on purpose, since its usefulness is negative in general case.
2022-10-28 00:01:16 +03:00
..
victoria-metrics Makefile: run errcheck for all the app/... subdirs 2022-09-30 18:35:53 +03:00
vmagent docs/enterprise.md: describe all the enteprise features in a short doc at https://docs.victoriametrics.com/enterprise.html 2022-10-24 18:02:03 +03:00
vmalert app/vmalert/templates: properly escape all the special chars in quotesEscape function 2022-10-28 00:01:16 +03:00
vmauth lib/envtemplate: allow referring env vars from other env vars via %{ENV_VAR} syntax 2022-10-26 14:49:33 +03:00
vmbackup doc: describe usage of env variables for obtaining credentials (#3219) 2022-10-10 21:56:46 +03:00
vmbackupmanager docs/enterprise.md: describe all the enteprise features in a short doc at https://docs.victoriametrics.com/enterprise.html 2022-10-24 18:02:03 +03:00
vmctl all: update the minimum required Go verson from 1.19.1 to 1.19.2 2022-10-07 22:43:37 +03:00
vmgateway docs/enterprise.md: describe all the enteprise features in a short doc at https://docs.victoriametrics.com/enterprise.html 2022-10-24 18:02:03 +03:00
vminsert lib/promrelabel: remove unconditional sorting of the labels in ParsedConfigs.Apply(), since the sorting isnt needed in many places 2022-10-09 14:51:16 +03:00
vmrestore docs/vmbackupmanager.md: update docs after adding the support to make backups to Azure blob storage 2022-10-08 10:30:39 +03:00
vmselect app/vmselect/vmui: make vmui-update after eae6063450 2022-10-26 02:50:46 +03:00
vmstorage lib/storage: add support for retention filters (aka multiple retentions for distinct sets of time series) 2022-10-24 16:40:20 +03:00
vmui fix: change step setting field (#3270) 2022-10-26 02:46:46 +03:00